Curious cron job question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Curious cron job question
# 1  
Old 11-10-2009
MySQL 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?

Code:
*/30 */3 * * */6 command

Something like that, should work in theory right? The above should in theory, count six days, then on the sixth day, wait until 3:30am then run the command. At which point it should then count six days, and also be counting every 30 minutes and every 3 hours, right? So the next time the sixth day comes around, the command would run at a completely different time of that day, right?

eg:

6.40am
9.50pm
12.10pm
5.20am

Does that make sense? I know I can do it in PHP but I would rather try do it this way, to avoid being forced to run things too heavily.

The */6 part, that'll work. But the minutes and the hours part. Will that work as I think it should, or will it only begin counting from the beginning each time? Resulting in the time the job runs, always being the same and ending up being no different to just using 30 3 * * */6 command? Which of course isn't what I want.
# 2  
Old 11-11-2009
completely different time of that day, right?

no, i think so....

that, */30 means 0 and 30, and */3 means 3,6,9,....


hours and min part will not vary, as far as i believe.. you can run a small R&D and confirm the same.

Last edited by thegeek; 11-11-2009 at 03:49 AM..
# 3  
Old 11-11-2009
You could perhaps create a small script that gets fired off every 6 days by cron and that schedules an at job at a random minute and hour on that day.
# 4  
Old 11-11-2009
Thanks for the replies guys!

@ thegeek
Yeah, you pretty much confirmed what I was afraid of. Lucky I didn't test it haha ouch.

@ Scrutinizer
Yeah, looks like I'll probably have to do something like that. I'm pretty sure I'm limited to creating new jobs via the cpanel in my case, but thinking I could setup two simple jobs, one to run a php script to generate a random time and store that somewhere as a string, then a second that runs more often which would only do something if a result matched the first generated time, using a simple if statement. That would make sure it only ran the every few days (via cron), and then only once at a random time.

Thanks for your help guys! Smilie

P.S. I suppose thinking about it, if the cron settings did work how I thought in my first post, it would ruin about 90% of everyone elses setups in the world wouldn't it. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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: 00,10,20 22,23,00 * * 2,4 MYCOMMAND Just wanted to verify this... (4 Replies)
Discussion started by: xdawg
4 Replies

2. 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

3. 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

4. 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

5. Shell Programming and Scripting

Curious question? How to put a string into two columns.

Now I have a list of numbers in hand and I try to put the numbers into two columns. Can I do this work with any script? Great thanks to your help! 1A1.log HF=-240.451527 HF=-240.5213996 1A2.log HF=-240.451527 HF=-240.5213996 1B.log HF=-240.4273718 HF=-240.4956636 1C.log... (7 Replies)
Discussion started by: liuzhencc
7 Replies

6. 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

7. 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

8. 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

9. 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

10. Shell Programming and Scripting

Cron job

Hi All , We have few scripts which uses common environment/path setting variables. Now instead of putting classpath , framework,java_home ..... etc. in all the script, can we make a file with all common settings which can be envoked by the scripts while running. If yes , say setting file is... (3 Replies)
Discussion started by: pankajkrmishra
3 Replies
Login or Register to Ask a Question