Jump to content

In Crontab

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Hektor

Hektor

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
In Crontab when does this execute:


58 23 1 * * <command>


How do I make it execute on the 1st and 15th? And what do each of the numbers/* mean?

#2
Tor

Tor

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 486 posts
That executes at 23:58 on the first of every month (thats in 24 hours time so 11:58pm). You can make it execute on the 1st and 15th by using this:

58 23 1,15 * * <command>

See the 1,15? The comma makes it use different days. So you could do 1,2,3,15,20,25 as many as you like.

The * mean:

* * * * *
Min Hour Day Month dunno about this one.. Year I guess. hehe.

#3
Hektor

Hektor

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
Ah, so it is delimited by spaces and commas allow multiple values.

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
It isn't year it is:


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)

Options
Instead of the first five fields, one of eight special strings may
appear:

string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".

Examples

# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"



5 4 * * sun echo "run at 5 after 4 every sunday"
This comes out of the man page for cron.