LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-18-2010, 07:49 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Rep: Reputation: 33
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 ?
 
Old 11-18-2010, 08:05 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
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
 
Old 11-18-2010, 08:16 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Original Poster
Rep: Reputation: 33
Thank you. This works.

Is it normal that the file /tmp/script.out is re-created every time ?!
 
Old 11-18-2010, 08:20 AM   #4
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing PHP script in crontab (include path problems) bar338 Linux - Newbie 5 12-21-2009 02:36 PM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 06:19 PM
crontab job not executing.... mia_tech Linux - Newbie 6 08-31-2009 02:42 PM
Run an external script, without holding up the currently executing script onesikgypo Programming 2 03-07-2009 09:26 PM
Command for executing C program in crontab bhandu Linux - Newbie 1 07-14-2007 12:54 PM


All times are GMT -5. The time now is 09:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration