
Rather than a single cron job, create multiple batches that combined result in the desired schedule.įor instance to run a batch every 40 minutes (00:00, 00:40, 01:20, 02:00 etc.) create two batches, one that runs twice on the even hours and second one that runs only the odd hours: # The following lines create a batch that runs every 40 minutes i.e.
#Ubuntu terminal not opening series
0,7,14,21,28,35,42,49,56 but between one hour and the next there will be only 4 minutes between batches, after 00:56 a new series starts at 01:00, 01:07 etc. */7 which matches every 7th minute from the minutes 0-59 i.e. Remember that the / character can be used to introduce a step but that steps don't wrap beyond the end of a series e.g. Which does not always run command every 7 minutes. Versus: */7 * * * * /path/to/your/command

It's not recommended to run sudo commands in a cron job, so if you're trying to run a sudo command in a user's cron, try moving that command to root's cron and remove sudo from the command.Ĭron is all things considered a very basic scheduler and the syntax does not easily allow an administrator to formulate slightly more uncommon schedules.Ĭonsider the following job which commonly would be explained to "run command every 5 minutes": */5 * * * * /path/to/your/command Will open the user's crontab, while sudo crontab -e When running as a non-root user, crontab -e Be sure to escape the percent signs * * * * * /path/to/command -day "$(date "+\%Y\%m\%d")" This is particularly intrusive when using the date command. Will create the ~/cron.out file containing the 3 lines foo * * * * * cat >$HOME/cron.out%foo%bar%baz To emphasise the advice about percent signs, here's an example of what cron does with them: # cron entry Restart cron and try it again without connecting to the internet (so the date doesn't have a chance to reset to one of the time servers). In this scenario, only asterisks would be accepted. The "minute" field will become ineffective after the hour is changed. This is crontab's attempt to try to "do what you want" when the time changes out from underneath it. If your date is recently changed by a user or system update, timezone or other, then crontab will start behaving erratically and exhibit bizarre bugs, sometimes working, sometimes not.
#Ubuntu terminal not opening how to
How to fix all of your crontab related woes/problems (Linux)
