Skip to main content

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:

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;
    }
?>
it works fine when run:
code:
/usr/bin/php /home/jeff/memory_script.php
but when add
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

Popular posts from this blog

Joomla 3.3 Installation Error message - Joomla! Forum - community, help and support

Multilanguage infinite redirect loop error. - Joomla! Forum - community, help and support

Thread: Wine can't find the cd