Reputation: 200
I need to run a script from crontab and this has a simple server load check that looks like this:
server_load=$(bash -c '/bin/more /proc/loadavg |
/usr/bin/cut -d" " -f1 | /usr/bin/cut -d"." -f1')
If I run the script from command line I get the server load, if I run it from crontab I get a strange and useless result.
I did look for posts with similar issues but nothing from what was suggested helped me solve my issue.
Upvotes: 1
Views: 228
Reputation: 43487
That whole line could be simplified to:
server_load=`cut -d. -f1 /proc/loadavg`
I suspect that the problems are related to more
wanting a terminal and thus emitting terminal control sequences.
Upvotes: 1