Thread: my script isn't running as a cronjob
i wrote myself little script give myself alert when system running low on memory. here script:
it works fine when run:php code:<?php
$mem_string = exec('cat /proc/meminfo | grep memfree');
$mem_string = str_ireplace('memfree:', '', $mem_string);
$mem_string = trim(str_ireplace('kb', '', $mem_string));
$mem_total = exec('cat /proc/meminfo | grep memtotal');
$mem_total = str_ireplace('memtotal:', '', $mem_total);
$mem_total = trim(str_ireplace('kb', '', $mem_total));
if($mem_total > 0){
$percentage = ($mem_string / $mem_total) * 100;
if($percentage < 10){
exec('notify-send " memory is low"');
}
}else{
return;
}
?>
but when addcode:/usr/bin/php /home/jeff/memory_script.php
22 * * * * root /usr/bin/php /home/jeff/memory_script.php
/etc/crontab nothing - having in /var/log/syslog shows:
code:aug 17 01:22:01 hardcore cron[986]: (*system*) reload (/etc/crontab) aug 17 01:22:01 hardcore cron[29564]: (root) cmd (/usr/bin/php /home/jeff/memory_script.php) aug 17 01:22:02 hardcore cron[29563]: (cron) info (no mta installed, discarding output)
have tried redirecting output file?
e.g. /usr/bin/php /home/jeff/memory_script.php &> /tmp/file.log
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk my script isn't running as a cronjob
Ubuntu
Comments
Post a Comment