Please help why my Crontab is not running on time?


 
Thread Tools Search this Thread
Operating Systems Solaris Please help why my Crontab is not running on time?
# 1  
Old 12-01-2011
Please help why my Crontab is not running on time?

I have set up my cron job on the solaris SunOS 5.10 Generic_138888-03 sun4u sparc SUNW,UltraAX-i2 but it is not running on time as expected.

Would you please help me to find out what I did wrong?

I want to have this cron job run once every month on the 1st Wednesday of the month, but it ran on Thursday.

# This cron job will run the pci1 every month on the 1st Wednesday at 2:00 PM GMT
Code:
0 14 1-7 * 3 /home/jdavid/PCI/pci1

Below is the log that cron job was run on Thu Dec 1st (/var/cron/log)
Code:
 Thu Dec  1 14:00:00 2011
>  CMD: /home/jdavid/PCI/pci1
>  jdavid 10812 c Thu Dec  1 14:00:00 2011

Thank you for all help.

Moderator's Comments:
Mod Comment Please use code tags -see PM

Last edited by zaxxon; 12-01-2011 at 02:19 PM.. Reason: code tags, see PM
# 2  
Old 12-01-2011
If you specify both Day of month and Day of week then the command will run when either are true (i.e. the 1st to 7th, and any Wednesday).
This User Gave Thanks to CarloM For This Post:
# 3  
Old 12-01-2011
Quote:
Originally Posted by CarloM
If you specify both Day of month and Day of week then the command will run when either are true (i.e. the 1st to 7th, and any Wednesday).
Ah!! Thank you very much CarloM.

So how do you fix my cron job, if I just want to run that cron job one on the 1st Wednesday of each month?

Thank you again.
# 4  
Old 12-01-2011
I don't think you can with just the crontab time parameters.

You could either work out the date of every first Wednesday (and have 12 crontab entries which need to change every year), or have an extra check on the date in the script (or the call to it).
# 5  
Old 12-01-2011
I seached and found this.

This line is and example of running a cron job every month, on Mondays whose dates are between 15-21. This means the third Monday only of the month at 4 a.m.
Code:
0 4 15-21 * 1 /command

I think you are right.

---------- Post updated at 12:35 PM ---------- Previous update was at 12:13 PM ----------

Here is the link for the example cron job above.

Cron and Crontab usage and examples

Last edited by ggcc; 12-01-2011 at 03:52 PM..
# 6  
Old 12-01-2011
Lateral thought idea.
1) Create a cron which creates a flag file at 00:01 on the first day of every month.
2) Run your cron every Wednesday but have a wrapper to exit if the flag file does not exist. If the flag file does exist, delete the flag file and run the main process.
This User Gave Thanks to methyl For This Post:
# 7  
Old 12-01-2011
Quote:
Originally Posted by methyl
Lateral thought idea.
1) Create a cron which creates a flag file at 00:01 on the first day of every month.
2) Run your cron every Wednesday but have a wrapper to exit if the flag file does not exist. If the flag file does exist, delete the flag file and run the main process.
Cool!! Thank you very much. I will do that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Crontab is not loading/running

hi, i have crontab where i have put my db backup scripts but crontab do not run at specific time. i have checkted the scripts andwhen run the script as ./mydbbkp.sh so it successfully run and do the job but from cron it is not running whihcmeans cron is not running. i have an oracle user under... (3 Replies)
Discussion started by: janakors
3 Replies

2. Shell Programming and Scripting

Crontab running bi-weekly

Hi experts, Need your help to schedule the script(test.sh) bi-weekly in linux machine. script need to run at every alernate thursday at 9 am . Please help to run the same. (6 Replies)
Discussion started by: abhigrkist
6 Replies

3. UNIX for Dummies Questions & Answers

crontab not running script

Hi All, I am having the below script to be run from crontab, it it doesnt run. 1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt when i run i manally it runs without any issues. Could please help me as to why doesnt it run the script.:( (7 Replies)
Discussion started by: abhi_123
7 Replies

4. UNIX for Advanced & Expert Users

Particular script not running through crontab

Hi, I have created the below script, set -x # Set the Path of Environment file ENV_FILE_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin LOG_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/log export ENV_FILE_DIR export LOG_DIR # Set Audit Environment . ${ENV_FILE_DIR}/QDM.env... (8 Replies)
Discussion started by: yohasini
8 Replies

5. UNIX for Dummies Questions & Answers

Issue while running from crontab

Hi All, Here is my command which I've scheduled to be run from crontab, but it's giving error message: rah: rahhost executable needed but not in PATH My cmd is- 36 10 * * * /opt/IBM/dwe/db2/V9.5/bin/rah "df -m" >> /db2home/bculinux/Files/log/db.out 2>&1 Though I've added path... (5 Replies)
Discussion started by: NARESH1302
5 Replies

6. Shell Programming and Scripting

Crontab not running a script

Hi, I posted this in the Solaris forum but I think this one would be more appropriate. I created a script starting with the following lines: #!/usr/bin/ksh flag=n export flag typeset -i quant=0 (...) When running it I'm getting the following 2 errors: /tmp/tstscript/testfail.ksh:... (9 Replies)
Discussion started by: Cvg
9 Replies

7. UNIX for Dummies Questions & Answers

crontab job not running

Hi all, down here part of the scheduled job in crontab (AIX Version 5) i have problem running jspPRE-ALL. i verrify permissions and privileges (the others job are working good) if i run the job in command line it work correctly # # Aggiornamento doni e continuity 00 02 * * 2-6... (5 Replies)
Discussion started by: ilpasta
5 Replies

8. UNIX for Advanced & Expert Users

Crontab is not running!!!

Hi experts, need your helpo. after editing the crontab while saving the file it says- "/tmp/crontabRlaauT" 1 line, 77 characters cron may not be running - call your system administrator And i checked after certain time. script in cron is not running. I got a mail in user saying... (1 Reply)
Discussion started by: thepurple
1 Replies

9. Shell Programming and Scripting

Start time/end time and status of crontab job

Is there anyway to get the start time and end time / status of a crontab job which was just completed? Of course, we know the start time of the crontab job since we are scheduling. But I would like to know process start and time recorded somewhere or can be fetched from a command like 'ps'. ... (3 Replies)
Discussion started by: thambi
3 Replies

10. UNIX for Dummies Questions & Answers

running sql in crontab

Hi, i have a scripts that update an SQL DATABASE using sqlplus command. when i run it in a interactive mode its ok but when try to run it using the crontab i get an a messege : "Must be attached to terminal for 'am I' option" (there is no "who am i" command in the script) and the DB... (4 Replies)
Discussion started by: dorilevy
4 Replies
Login or Register to Ask a Question