Cron job question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cron job question
# 1  
Old 02-24-2015
Question Cron job question

Hi,
I have a cron job that I want to run twice a week, on Tues/Thurs, and I want it to run three times - specifically at 10pm, 11:10pm, and 12:20am respectively.

I "think" the way to do this is to run the following:

Code:
00,10,20 22,23,00 * * 2,4 MYCOMMAND

Just wanted to verify this is correct?

Last edited by Scrutinizer; 02-24-2015 at 01:15 PM.. Reason: code tags
# 2  
Old 02-24-2015
Hi.

No, that is not correct. That will run the job at 22:00, 22:10, 22:20, 23:00, 23:10. etc.

There's no way to schedule the job in that way in a single job.

You could either compromise, by running it at, say, 22:10, 23:10, etc.; or programmatically control it from within your script; or create three separate cron jobs (the easiest option).

Code:
00 22,23,00 * * 2,4 MYCOMMAND
10 22,23,00 * * 2,4 MYCOMMAND
20 22,23,00 * * 2,4 MYCOMMAND

This User Gave Thanks to Scott For This Post:
# 3  
Old 02-24-2015
Quote:
Originally Posted by Scott
Hi.

No, that is not correct. That will run the job at 22:00, 22:10, 22:20, 23:00, 23:10. etc.

There's no way to schedule the job in that way in a single job.

You could either compromise, by running it at, say, 22:10, 23:10, etc.; or programmatically control it from within your script; or create three separate cron jobs (the easiest option).

Code:
00 22,23,00 * * 2,4 MYCOMMAND
10 22,23,00 * * 2,4 MYCOMMAND
20 22,23,00 * * 2,4 MYCOMMAND

Ok thanks, that's what I needed to know Smilie
# 4  
Old 02-24-2015
Unfortunately, this
Code:
00 22,23,00 * * 2,4 MYCOMMAND
10 22,23,00 * * 2,4 MYCOMMAND
20 22,23,00 * * 2,4 MYCOMMAND

wouldn't help at all; the script would still run at 22:00h, 22:10h, 22:20h, 23:00h etc.
Try
Code:
00 22 * * 2,4 MYCOMMAND
10 23 * * 2,4 MYCOMMAND
20 00 * * 2,4 MYCOMMAND

This User Gave Thanks to RudiC For This Post:
# 5  
Old 02-24-2015
Oh yes.... a clumsy cut and paste oversight, thanks Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. Shell Programming and Scripting

Curious cron job question

Wow that was annoying, I wrote a huge long entire post out, clicked submit and the damn thing lost my entire post. Ok, here's what I am needing to do. Have a cron job run every six days at a random minute and hour ONLY ONCE on that day. Would this work? */30 */3 * * */6 command ... (3 Replies)
Discussion started by: Ashberry
3 Replies

5. UNIX for Dummies Questions & Answers

cron job

Hi, How to monitor whether a cron job is running or errored out..?other than checking the process using ps-aef how to enter the cron job which throws the output in 1 file and errors in other file. i remember it can be done using >1 and >2 ..but not sure.. any expert..please help!! (1 Reply)
Discussion started by: rujus
1 Replies

6. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

7. Linux

cron job question

I created a cron script that runs on the command line but not in crontab. What could be causing it to not run ? (5 Replies)
Discussion started by: dannyd
5 Replies

8. UNIX for Dummies Questions & Answers

CRON usage for CRON job

can anybody explain the usage of CRON for adding a cron job. please provide an example also for better understanding !!! Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

9. UNIX for Dummies Questions & Answers

Cron Job

Hi everybody ....I am trying to write a cron job for event based subscription for a tool called Microstrategy...if anybody have idea about this please help me... Thanks in advance ark (7 Replies)
Discussion started by: arksal
7 Replies

10. Shell Programming and Scripting

cron job

how do you schedule a job to run at the last day of the in a single crontab line for example if I put a crontab entry of 0 0 31 * * /path_of_my_script the above will only run if the last day of the months is 31, what happens if the last day of the month is 28 or 30. if I put a crontab... (4 Replies)
Discussion started by: hassan2
4 Replies
Login or Register to Ask a Question