2

How would I set a script to execute on every Tuesday and Thursday at 11:50am?

I've been looking at the at command, but I can't conceive how to use it the way I need to from its man page.

  • Depending on your intit system, you could also use a systemd.timer... – jasonwryan Oct 30 '14 at 5:03
4

at is excellent tool for one-off commands. To run a program repetitively at the same times, however, the right tool is cron. Run crontab -e. It will open an editor. Add this line and save the file:

50 11 * * 2,4 /path/to/script

This will run /path/to/script every Tuesday and Thursday at 11:50am. crontab runs programs in a limited environment. So, script may need to set its own PATH, etc.

If the machine has a properly set up mail server, any output from script will be e-mailed to the user who owns the crontab file. Alternatively, output will be mailed to the address specified by the MAILTO variable in the crontab file. See man 5 crontab for details.

The first five columns of the line above define the time that the program is run. Their meaning is documented in man 5 crontab to be:

          field          allowed values
          -----          --------------
          minute         0-59
          hour           0-23
          day of month   1-31
          month          1-12 (or names, see below)
          day of week    0-7 (0 or 7 is Sun, or use names)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.