I am trying to generate a cpu usage log and have it emailed to
me every evening. The log works by using the shell top command, which takes a
snapshot of the cpu usage at any given point. I set up 3 entries for a Perl
script in /etc/crontab, so that the script runs three times a day. I have tested
the perl script thoroughly on the command line, and it works perfectly. However,
whenever cron executes the script, the shell commmand in perl doesn't execute
properly. Here is the shell command taken directly from the perl
script:
$log = `top -n 1 -b`;
The $log variable receives the correct info when I run from
the command line. But when the script runs from crontab, the $log variable
doesn't get anything. Does anyone know why this is? Below is an
example of my crontab entry:
1 12 * * * root
/home/sites/home/users/admin/bin/cpu_log-build.pl
I have tried a number of different things, like specifying the
full path to the top executable, and I have searched the knowledge base for
everything relating to cron.
Thanks,
Kevin DeMello
|