I wrote this shell script named example.sh on Linux.
#!/bin/sh
TOPLOG=/tmp/top.log
date +%H:%M:%S >> ${TOPLOG}
top -b -c -n 1 |head -n 8 |tail -n 2 >> ${TOPLOG}
echo >> ${TOPLOG}
When I run it with the command "sh /tmp/example.sh", texts in top.log is like
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17980 cybereas 20 0 1478m 73m 18m S 2.0 0.5 1360:59 /opt/cybereason/sensor/bin/cybereason-sensor
However, when I run this script with this crontab
*/1 * * * * sh /tmp/example.sh
texts in top.log is shown like
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17980 cybereas 20 0 1478m 73m 18m S 2.0 0.5 1360:59 /opt/cybereason/sen
The output of "COMMAND" is omitted when it is a little long.
Is there any solution for this? I appretiate for any idea. Thank you.