Crontab Execution


 
Thread Tools Search this Thread
Operating Systems HP-UX Crontab Execution
# 1  
Old 11-24-2014
HP Crontab Execution

Hi Guys,

I need help to clear my doubt w.r.t Crontab execution.

HTML Code:
uname -a
HP-UX myservername B.11.31 U ia64 1422528451 unlimited-user license
I created a crontab entry to execute particular job on Saturday 11/15/2014 11:22
Below is the cron entry
HTML Code:
#refresh DEVDB from PRODDB
22 11 15 11 6 /stage01/refresh/database/DEVDB/scripts/refresh_DEVDB.ksh > /tmp/refresh_DEVDB.log 2>&1
I assumed this job will execute only once on Saturday 11/15/2014 11:22 but unfortunately this job executed automatically on following saturday also i.e. 11/22/2014 11:22 [ Saturday ]
Is it supposed to work this way ? Is specifying day in cron is OR condition ?

Pls advice.
# 2  
Old 11-24-2014
Yes...
What you have on your line is I read: Execute in november on the 15th and all saturday...
If you wanted an a specific day you should have wrote a line with just the month day since you have chosen a specific month it can only be the day you want...
# 3  
Old 11-24-2014
Thanks for your reply.
So as per my entry, will it not execute only once as in Nov 15th and Saturday wil come only once ?
Can you please provide the entry I should have used to execute job on Nov 15, 11:22 [ once in lifetime/Year ]. This raises another question in my mind. There is no specification for year so this job will execute every year right ? Is ther way to specify only current year ?
# 4  
Old 11-24-2014
Sorry I was very unclear, I forgot that I meant in that case since only executing once:
it would have been using at command
As for cron:
Code:
# ==========================================================================
#      F O R M A T
# ==========================================================================
#  Minute    Hour    Month_Day    Month    Weekday    Command
#  (0-59)   (0-23)   (1-31)       (1-12)   (0-6)*0=sun run-string
#  * = in any crontab field represents all legal values.

Keep above in mind
So
22 11 15 11 6 would be at 11:22 on the 15th - and saturdays of November!
the monthday and day of week are to be understood as "and also on "
In any case you would have to write a test :
For saturdays, your job should test on the date: Is it the 15th?
For the 15th day of month, test if its a saturday...
Search the forums for examples in shell programming forum
# 5  
Old 11-24-2014
You have two problems: Nov 15 is not a Saturday every year and you will have to test the year either in your script or in the crontab line:
Assume you want 2015:

crontab example:

Code:
22 11 15 11 * [ `date +%Y` - eq 2015 ] && /stage01/refresh/database/DEVDB/scripts/refresh_DEVDB.ksh > /tmp/refresh_DEVDB.log 2>&1

script
Code:
#!/bin/ksh
# this is called a guard structure (or block)
if [ `date +%Y` -eq 2015 ] ; then

# all of your old script goes here
# or you can simply call your old scipt:  /path/to/myscript.sh

fi  # end of guard block

This is not a good use of crontab. I suspect you want to run this thing the third Saturday of every November, not just once every 5-7 years. IF you need to run it JUST ONCE, the use at:

You should refer to your man page for the at command, because some varieties of at use slightly different syntax. I think HP's at is one of them.
# 6  
Old 11-24-2014
Thank you all for responses.
# 7  
Old 11-24-2014
Thanks for responses/help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution Problems with Crontab

Dear Folks, I have written a shell script which internally connects to oracle database through sqplplus command line. The script runs fine when run manually. Now I am scheduling it to run (Linux environment) from crontab. In crontab it is failing with an error: sqlplus command... (6 Replies)
Discussion started by: tamojitc
6 Replies

2. Shell Programming and Scripting

Problem with Job execution using crontab

Hi All, I am facing a problem with crontab.I made an entry in crontab like this 05 07 * * * /afs2/cdwfullacc/current/exe/cdw_generate_special_klant.sh > /afs2/cdwfullacc/current/scratch/cdw_gen_cron.log But job was not getting executed. Entry in crontab was made with same user by whom... (4 Replies)
Discussion started by: krishna_gnv
4 Replies

3. Shell Programming and Scripting

Execution of Unix script after every second without crontab

Hi, I have shell script "A" which is executing oracle pl/sql procedure and initiate its multiple threads at a time as below on given user value in an other script "B". I want to execute script "A" after every second with out cron tab as " A " will keep on executing after every second till... (1 Reply)
Discussion started by: saad.imran@gmai
1 Replies

4. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

5. UNIX for Dummies Questions & Answers

Problem with Crontab execution

Hi I have shell script to excute the SQL script.And i have scheduled those shell script in crontab.But the Shell script is not running timely and i got the below error Crontab entry 15 05 17 7 * /export/home/vcpsapp/vcps/stat.sh Output Your "cron" job on uspxivus16... (3 Replies)
Discussion started by: mak_boop
3 Replies

6. UNIX for Dummies Questions & Answers

Unscheduled crontab execution

Hi All, Do apologise, for it has been a long while since I was last on the forum. I've been doing documentation and primiarily Windows efforts for some while now. :( We are running a HP-UX 11.23 unit. This morning two separate crontab users executed shutdown scripts of their respective... (14 Replies)
Discussion started by: Cameron
14 Replies

7. UNIX for Dummies Questions & Answers

Execution problems with crontab

I need your help please Inin a production system i found crontab entries was removed because i typed crontab -l with username corasc and didn't show anything. i asked the administrador to restored the mentioned crontab, he restored the crontab: The problem is when restored the crontab file is... (2 Replies)
Discussion started by: alexcol
2 Replies

8. Shell Programming and Scripting

crontab execution

is it possible to soecify time overnight in 5 days for example: 0 18-7 * * 1-5 /mycode is this okay to use 18-7 because im not getting the results correctly? (4 Replies)
Discussion started by: vadharah
4 Replies

9. Shell Programming and Scripting

execution without ./

I want to execute a shell script without ./ symbol. For example: ./my_script ===== my_script (both of them can execute my script) both of them are the same as result. (7 Replies)
Discussion started by: mehmetned
7 Replies

10. UNIX for Dummies Questions & Answers

execution without using (./)

I want to execute a shell script without ./ symbol. For example: ./my_script ===== my_script (both of them can execute my script) both of them are the same as result. (2 Replies)
Discussion started by: mehmetned
2 Replies
Login or Register to Ask a Question