Issue
I have this cronjob: (it's a single line, I formatted it only here for better readability)
* 5-7 * * * (
sudo pstree -pa > "$HOME/log/`date "+\%F-\%T"`-pstree.txt";
sudo top -o \%MEM | head -25 > "$HOME/log/`date "+\%F-\%T"`-topMEM.txt";
sudo top -o \%CPU | head -25 > "$HOME/log/`date "+\%F-\%T"`-topCPU.txt"
)
The first command runs successfully, the file is created with pstree inside it.
But the second and third commands fail and result in empty files.
The only info in the the mail is:
'unknown': unknown terminal type.
I'm just starting out with Debian, etc, so sorry for the newbie question, any advice is welcome! :)
Solution
top's -b
(Batch-mode) and -n
(Number-of-iterations) options helped.
By default top is interactive so I have fetch a static result to save it into a file.
Example: top -b -n1
Answered By - Tudvari Answer Checked By - Cary Denson (WPSolving Admin)