Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say I do this:

0 0 0 * * somejob

Will this run on a set date, and if my computer is not no at that date will it skip that week?

Let's say I set this job right now. And then my computer is turned off 5 days from know for the whole day.

Basically I need something to run every week, but my computer may not be on 24/7.

share|improve this question
You will need to keep the machine running in order for the job to be run... – nicorellius Jul 10 '10 at 23:05
up vote 4 down vote accepted

Yep, cron will only run a job scheduled for a specific time if the computer is on at that time. The way it works is that each minute, it checks all scheduled cron jobs to see if their time fields match the current minute, and if so, it runs the job. If not, it gets skipped. There's no concept of "saving" the execution of a job for a later time.

What you could do, for your situation, is use a marker file to indicate the last time the job was run. Create a little script or program that looks like this (this is pseudo-Bash syntax):

if (marker file was last modified > 1 week ago); then
    run the job
    touch marker file

and you can set that script as a cron job to run every day, every hour, or even every minute - as often as you need to ensure that it will run at least once each week during the time you have your computer on.

share|improve this answer

Anacron is likely what you're looking for:

Anacron is a periodic command scheduler. It executes commands atintervals specified in days. Unlike cron, it does not assume that thesystem is running continuously.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .