Cron Job Weekday Flexibility


Hello Friends,

I am trying to get a cron job that can run at different hours depending what day of the week it is. I go to create a cron job in the goodies section and it only lets me do the same hours and minutes for every day of the week (for example, I can’t have the job run at noon on Sunday and not run at noon on Monday).

I tried creating a second Cron job with the same command but it would not let me do it (told me i’m not allowed to create another cron job with the same command, pretty lame). All I am doing in the cron job is calling a script on a web site…

Is there any way I can get the flexibility I am looking for? I have no experience making cron jobs outside of the interface dreamhost provides so go easy on me. Other than additional commands, perhaps I could trick dreamhost into allowing me to use the same command twice somehow (creating a second page at a different url with modified code slightly that does the same thing)?

Thanks for your help,



like most things *nix there is more than one way to do this…

About cron, in general, by default across the board, cron runs something when various ‘time’ interval values are tested with an “AND” between each of the interval values… such as ‘monday’ AND hour ‘12’… you can get fancy with the way you express these but the “AND” between each interval value will always be the case, there is no “OR” or “IF”. This is NOT dreamhost specific.

What would probably be considered most correct is for your script to be modified so that it simply exits if it runs at a time that is it’s not desired… Meaning you would use cron to specify all possible overlapped times, then the script itself simply exits if it’s noon on Tuesday and it’s not supposed to do anything then. However I’m guessing if the basic cron interface is causing you problems, then modifying your script to work that way also will…

Another way, and you were on the way there yourself, is to make a shell script for each time the script is to run

/usr/local/php5/bin/php /home/USER/EXAMPLE.COM/cron.php

NOTE: there is a space in the line above.

Change USER and EXAMPLE.COM to match your user and domain. If the cron.php script has more path to it then modify the above such as: /usr/local/php5/bin/php /home/USER/EXAMPLE.COM/PATH/TO/cron.php

Save multiple copies with file names that make sense to you, adding .sh to the end of the name, like etc

Upload all those files to /home/USER/ (it doesn’t need to be in

Make the permissions on each of these files are 755.

then set up multiple cron entries in the panel make the command to execute:


Most of the limitations you are running into are not Dreamhost specific but true of how cron would behave anywhere.


Thank you LakeRat, I did not think of the first proposal you suggested and that would be easiest for me. That provided me a solution and you were very helpful. I will just enclose my script with a giant if statement in PHP and make sure it does not run during the selected times. Thank you. You truly are OnePigWhoShouldRuleThemAll…