1835421 Members
2581 Online
110078 Solutions
New Discussion

Re: cron help

 
Zee
Advisor

cron help

I need to run a job twice every day, first at 08.00AM and then again at 05.30PM

I know i can do these ..

00 08 * * * /jobname
30 17 * * * /jobname

But is there any way i can set it to run first at 0800 and then at 1730 in once cron command ?

Thanks in advance,
Zee.
8 REPLIES 8
Peter Godron
Honored Contributor

Re: cron help

Zee,
if the start time was 17:00 you could with:
00 08,17 * * * /jobname

Otherwise you could use a conditional at in the 08:00 run

Regards
Jeff Schussele
Honored Contributor

Re: cron help

Hi Zee,

Sure - use the at command.
Just make the last command in the cron job an at command timed for 17:30 that day.

man 1 at

for details.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
A. Clay Stephenson
Acclaimed Contributor

Re: cron help

No, if you tried to combine your commands into something like
00,30 08,17 * * * /jobname then the command would execute 4 times per day. You could put an "at" command in /jobname but that would be more complicated and error prone that your current method.
If it ain't broke, I can fix that.
Pete Randall
Outstanding Contributor

Re: cron help

You could cron it to run at 8:00 and put an at statement to kick it off again at 5:30:

echo "full_path_name_of_job" |at 1730 today


Pete

Pete
Geoff Wild
Honored Contributor

Re: cron help

or...if job name is a script...

#
# Loop
#
count=1
_ret=1
while [ $count -le 2 -a $_ret != 0 ]
do

your commands...

count=$((count + 1 ))
sleep 34200
done


or something like that...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Sanjay_6
Honored Contributor

Re: cron help

Hi Zee,

It is best to setup two cron jobs under the circumstances unless you want to run one at 8:00am and the other at xx:00 AM/PM.

Hope this helps.

Regds
Rick Garland
Honored Contributor

Re: cron help

You may be better off using the 2 lines in the cron.

Nice idea though
Zee
Advisor

Re: cron help

thank you all.