LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Seems crontab is not executing script... (https://www.linuxquestions.org/questions/linux-newbie-8/seems-crontab-is-not-executing-script-845064/)

jonaskellens 11-18-2010 07:49 AM

Seems crontab is not executing script...
 
When I execute the script as root :

Code:

[root@asterback ~]# php ~/script
output:    final received
return: 1
[root@asterback ~]# /sbin/service crond status
crond (pid  4082) is running...

I have this in crontab -e :

0,5,10,15,20,25,30,35,40,45,50,55 * * * * php ~/script #test connection

The script consists of php echo statements...

Any reason why I don't see output on my CLI ?

PMP 11-18-2010 08:05 AM

Quote:

Any reason why I don't see output on my CLI ?
Crond is executing this statement in another shell, different from your current shell.

Not sure whether this will work or not.
try using absolute path while writing entry in crontab,

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /path/to/php /home/user/script > /tmp/script.out 2> /tmp/script.err #test connection

Now if your script run fine you will see your console output in /tmp/script.out and if it doesn't you will find it in /tmp/script.err

jonaskellens 11-18-2010 08:16 AM

Thank you. This works.

Is it normal that the file /tmp/script.out is re-created every time ?!

PMP 11-18-2010 08:20 AM

Thats your wish,

In case you want to keep the output of every run of the scirpt you can change the redirection ">" to ">>".
In existing case it will create the new error and the log file everytime.


All times are GMT -5. The time now is 04:54 AM.