LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 02-17-2009, 10:35 PM   #1
shajay12
LQ Newbie
 
Registered: Jan 2009
Posts: 28

Rep: Reputation: 0
Smile Scripts in the crontab not running on the scheduled time


Hi

I have scheduled some scripts in the crontab.

The first two scripts run very well at their scheduled time.

But the last script doesn't runs at the scheduled time.

Though the script runs very well when i run it manually.

I have changed its chmod, so that every one can execute it.

But still the scripts doesn't runs at scheduled time.

I would request you to please let me know the answer.

Thanks,
Ajay
 
Old 02-17-2009, 10:57 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by shajay12 View Post
Hi

I have scheduled some scripts in the crontab.

The first two scripts run very well at their scheduled time.

But the last script doesn't runs at the scheduled time.

Though the script runs very well when i run it manually.

I have changed its chmod, so that every one can execute it.

But still the scripts doesn't runs at scheduled time.

I would request you to please let me know the answer.

Thanks,
Ajay
Post the output of...
Code:
root@host# crontab -l
And
Code:
root@host# cat script_in_question.sh
...where script_in_question.sh is the script that you are talking about...

-C
 
Old 02-18-2009, 03:16 AM   #3
shajay12
LQ Newbie
 
Registered: Jan 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Hi Custangro,

Thank you for the reply. But i am not able to understand how why i should use cat.

Because using cat i can only view the file.

then how does it helps me so that the crontab scripts runs.

Thanks,
Ajay
 
Old 02-18-2009, 03:28 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The request by custangro is wise, since if we can see the content of the script (unless it is an X-file) we can have a clue of the issue which prevents the execution from crontab. A typical recommendation is to use absolute paths for the commands within the script, because the crontab runs with a very limited environment and the PATH is usually limited to /bin:/usr/bin. Also in a crontab entry you have to follow some rules about special characters: for example the percent sign %, if written in a crontab, has a special meaning and you have to escape it in order to get the expected behaviour.

So if you show us the actual crontab and the content of the script, we can be more helpful.
 
Old 02-18-2009, 10:14 AM   #5
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by shajay12 View Post
Hi Custangro,

Thank you for the reply. But i am not able to understand how why i should use cat.

Because using cat i can only view the file.

then how does it helps me so that the crontab scripts runs.

Thanks,
Ajay
So I can take a look at the script...also colucix is right; seeing your crontab would be helpful to

-C
 
Old 02-18-2009, 08:35 PM   #6
jonesr
Member
 
Registered: Feb 2008
Location: Sacramento
Distribution: RHEL AS, mostly
Posts: 44

Rep: Reputation: 18
Also, have you checked /var/log/cron for messages generated around the time that the script is supposed to run?
 
Old 02-19-2009, 02:43 AM   #7
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by shajay12 View Post

But the last script doesn't runs at the scheduled time.

Though the script runs very well when i run it manually.
Usually when script run from the command line and doesn't from the cron
it's problem with PATH.

But as was already said seeing your script can help.
 
Old 02-20-2009, 12:24 PM   #8
shajay12
LQ Newbie
 
Registered: Jan 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Thank you everyone for your help

Below is a crontab that is on Linux 64 bit machine and similarly i have scheduled the crontab on solaris machines also. But only the bewlow script doesn't runs on any machine.

Here is the script that is causing problem.
scripts starts from here:-

#!/usr/bin/ksh


echo "##############################################"
echo "###### Starting new reporting ################"
date
rm /gfs/wlv/colfax/d1/local/XXX/hptolemy/test/scripts/logs/logs-Linux-46-colfax/*.xml

perl /gfs/wlv/colfax/d1/local/XXX/hptolemy/test/scripts/asimlog2xml.pl -m 32bit -S wlv -f /gfs/wlv/colfax/d1/local/XXX/hptolemy/test/scripts/logs/logs-Linux-46-colfax/autosim.log -t /hfs/d1/local/XXX/hptolemy/test/autosim/

rsh koa curl "http://etna.wlv.agilent.com/regression/parser/sc_parse_xml.php?_xmlfile=/gfs/wlv/colfax/d1/local/XXX/hptolemy/test/scripts/autosim.xml"

date

scripts ends here

Below is the look of the crontab

# DEV XXX RSTABLE ptolemy
0 11 * * 0,1,2,3,5,6 ksh /hfs/d1/local/XXX/hptolemy/test/scripts/cvs_update_XXX.sh > /hfs/d1/local/XXX/hptolemy/test/scripts/cvs_sync.log 2>&1
0 11 * * 0,1,2,3,5,6 ksh /hfs/d1/local/XXX/hptolemy/test/scripts/rsync_XXX_rstable.sh > /hfs/d1/local/XXX/hptolemy/test/scripts/linux_sync.log 2>&1
0 12 * * 0,1,2,3,5,6 ksh /hfs/d1/local/XXX/hptolemy/test/scripts/start_list_gen_autosim1_cfx > /hfs/d1/local/XXX/hptolemy/test/scripts/list_gen.log 2>&1

0 13 * * 1,2,3,5,6 ksh /hfs/d1/local/XXX/hptolemy/test/scripts/start_regress_test_autosim1_cfx_cl > /hfs/d1/local/XXX/hptolemy/test/scripts/autosim1_log_cfx_cl 2>&1

0 19 * * 0,1,2,3,5,6,6 ksh /hfs/di/local/XXX/hptolemy/test/scripts/start_dsdiff_report_gen_autosim1_cfx_cl_pista

The last script start_dsdiff_report_gen_autosim1_cfx_cl_pista
is causing problem. This is a report generation script. It doesn't runs at the scheduled time.

And sorry but i haven't checked for this question. **Also, have you checked /var/log/cron for messages generated around the time that the script is supposed to run?**

I am not aware of the above question. Please let me know what is the answer.

Regards,
Ajay

Last edited by shajay12; 02-20-2009 at 12:25 PM. Reason: wanted to confirm
 
Old 02-20-2009, 12:37 PM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Try to put full paths of the commands within the script: /usr/bin/perl in place of perl, /bin/date in place of date and so on. This is a general rule for crontab scripts, since the PATH of cron is limited in respect of the PATH available to the shell.

Moreover, since you did not redirect the standard error and/or the standard output of the last job, try to see if the owner of the crontab received a mail with some clarifying message. By default stderr and stdout are sent by mail, that one you can see using the command mail from a terminal. If something is wrong, you will find some message from the cron daemon there.
 
Old 02-20-2009, 01:28 PM   #10
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by shajay12 View Post
rsh koa curl "http://etna.wlv.agilent.com/regression/parser/sc_parse_xml.php?_xmlfile=/gfs/wlv/colfax/d1/local/XXX/hptolemy/test/scripts/autosim.xml"
Also make sure that RSH is working between hosts...

-C
 
Old 02-21-2009, 04:26 AM   #11
shajay12
LQ Newbie
 
Registered: Jan 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Hi Custangro,

I have made the changes you have suggested.

And i have scheduled the scripts. I would report whether i have got some results.

Thanks for your valuable answers.

Thanks,
Ajay
 
Old 02-23-2009, 03:11 AM   #12
shajay12
LQ Newbie
 
Registered: Jan 2009
Posts: 28

Original Poster
Rep: Reputation: 0
Hi Custangro,

I did all the changes you had suggested but yet the script doesn't runs from crontab.

I would make more research why this doesn't runs. And i would let you know the results with a day.

Thank you everyone for giving the suggestions.

Regards,
Ajay
 
Old 02-23-2009, 03:46 AM   #13
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Doesn't it run or does it abort at a very early stage? You can check the file /var/log/cron to see if the cron daemon actually run the script at the scheduled time or if it just ignored it. For example, you should see an entry like this:
Code:
Feb 22 19:00:01 ocean-4 crond[342]: (shajay) CMD (ksh /hfs/di/local/XXX/hptolemy/test/scripts/start_dsdiff_report_gen_autosim1_cfx_cl_pista)
Also check the system mail of the owner of the crontab. If the script actually runs, all the generated standard output and standard error is sent to the user by mail (if not redirected to a file).
 
Old 02-23-2009, 08:54 AM   #14
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by shajay12 View Post
Hi Custangro,

I did all the changes you had suggested but yet the script doesn't runs from crontab.

I would make more research why this doesn't runs. And i would let you know the results with a day.

Thank you everyone for giving the suggestions.

Regards,
Ajay
One thing you can try is using the "debugger"...start your script like this...

Code:
#!/usr/bin/ksh -x
the "-x" shows you what it's doing (since it's in a cron, it should email you the output).

-C
 
  


Reply



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
some cool crontab scripts djgerbavore Linux - Newbie 1 05-25-2005 09:14 AM
Crontab - How can i run the scheduled file? - Please help me b:z Linux - General 6 04-01-2005 05:23 AM
is there anyway to make linux turn on at a scheduled time? jontyrhodes Linux - General 2 06-04-2004 01:04 PM
crontab and scripts Kent Emia Linux - General 6 10-02-2003 05:47 AM
Running scripts at boot time saintt Linux - Software 1 08-09-2002 05:03 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration