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

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.

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.

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.

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! :slight_smile:

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