I am monitoring my cloud server so I wrote a script using
top command and stored the output file in single line with date , but its not working
(date)&&(top -n 1 | grep firefox) >> filename.txt
Kindly help me
The following command should work:
((date | tr -d "\n")&&(top -b -n 1 | grep firefox)) >> filename.txt
I enclosed in parentheses the full command so that even the
date output is redirected to the file, the
tr part just removing the carriage return.
top in batch mode
-b to get the full list of processes.