An extremely terse cron intro

I mentioned cron in the last post, but I think aside from that brief example, I’ve barely ever written about it.

There’s no real reason for that, except that I don’t use it very often and so as a result I don’t mention it. Hopefully the logic in that is clear. :roll:

It’s not too difficult to set up or understand though, and so the example I gave yesterday makes a good starting point. Here are those lines again.

00  * * * * /usr/bin/python /home/kmandla/.xplanet/download_clouds.py /home/kmandla/.xplanet/clouds_2048.jpg
00 23 * * * /usr/sbin/vbetool dpms off
30 06 * * * /usr/sbin/vbetool dpms on

You can edit crontab by entering crontab -e (of all things) and your defined $EDITOR will take over.

The gist of cron — for me — is simply this: Those two first numbers are the time you want the action performed, listed in reverse.

So “00 23″ is actually 11 p.m., listed minutes first then hour. Every day at 11 p.m., that command is run. And “30 06″ is 6:30 a.m.

The “00″ without a number, with only a splat next to it, means every hour on the hour. Like I mentioned yesterday, I don’t know exactly when the weather maps are updated, so once an hour is probably enough.

Everything I’ve shown there runs daily, but if I wanted a command run on a particular day of the month, I could list the day number next.

So it should follow that the next column is the month. And the last column? The day of the week, with Sunday as day 0.

That’s the long and short of it. You can tell cron to do whatever, whenever via crontab. After restarting cron for good measure, you should be set. So for one last example:

15 05 * * * 6 /usr/bin/yaourt -Syu

Every week at 5:15 a.m. on Saturday, a system-wide update.

If you need more details or if you have a huge slew of commands you want run at the same time check out the Arch wiki page for cron. Once again, the Arch wiki is the best resource around. …

About these ads

6 Responses to “An extremely terse cron intro”


  1. 1 aperson 2011/02/14 at 11:45 AM

    Actually, I think Ubuntu’s wiki page for cron gives a tad more detail than Arch’s in this case (Though I think Arch’s is clearer to read in some respects).

    https://help.ubuntu.com/community/CronHowto

    • 2 livibetter 2011/02/14 at 12:21 PM

      In my opinion, I would recommend `man 5 crontab`, that’s the best source because every cron program may have some differences between them. (I use vixie-cron)

      And that’s how I learn about how to get rid of `/usr/bin/foo` or `/home/username/bin/bar`, make them to be just `foo` and `bar`.

      PYTHONPATH=”/home/username/lib/python2.5:/usr/local/lib64/python2.6″
      PATH=”/home/username/bin:/usr/bin:/bin”

      I have these lines before my cron table. Additionally, I have

      #Mins Hours Days Months Day of the week

      right above cron jobs, tab-separated valued, so I don’t need to double check every I need edit my table.

  2. 3 bmc5311 2011/02/15 at 3:32 AM

    cron + rsnapshot (rsync) = poor man’s time machine.

    That’s how I do my backups, hourly, daily, weekly and monthly.

  3. 5 Kulutusluotot 2011/02/16 at 3:02 AM

    I think very few people actively use cron, even if their system uses it for rotating logs etc.


  1. 1 Links 14/2/2011: GNU/Linux Education in Valencia, London Stock Exchange Goes Live With GNU/Linux | Techrights Trackback on 2011/02/15 at 12:27 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,963,198 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: