feed-image  ISSN 1836-5930



Receive Your Complimentary Guide to Linux NOW!


A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)




Poll

Do you care about your privacy when using a FACEBOOK?
 

linuxconfig.org
is hosted by:



Partner Linux Sites
TuxMachines
DebianAdmin
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
FreeSoftwareLinux
All For Linux

Linux Cron Guide
Article Index
1. Introduction
2. Cron job examples
3. System wide cron scheduler
4. Cron Scheduler on user level

1. Introduction

Every user as well as administrator of the linux system very often needs to execute some programs on regular basis.

 

For example, an administrator may need to monitor a disk usage of a system. In this case a cron scheduler is very handy tool to achieve this. Let's say that root needs to execute /usr/local/sbin/backup.sh script every Sunday at 2:36AM he would edit his crontab file as shown on the figure below:

 

# crontab -e 

 

The format is simple, 6 fields separated with spaces or tabs. The rest of the line is the command, and it's parameters to be executed. The sixth field - user name (in blue) is used only in the system wide cron scheduler.linux cron

2. Cron job examples

Crontab Example 1: This crontab example runs updatedb command 35 minutes past every hour.

35 * * * * updatedb 

Crontab Example 2: This crontab example runs /usr/local/bin/diskusage.sh every 5 minutes (e.g. 0, 5, 10, 15, ...).

*/5 * * * * /usr/local/bin/diskusage.sh 

Crontab Example 3: This crontab example runs /usr/local/bin/diskusage.sh at 1:25 AM, 1:50 AM every Tuesday and on 15th of every month.

25,50 1 15 * 2 /usr/local/bin/diskusage.sh 

Crontab Example 4: This crontab example runs /usr/local/bin/diskusage.sh at 2:00 PM on 10th of March, June, September and December.

00 14 10 3,6,9,12 * /usr/local/bin/diskusage.sh 

Crontab Example 5: This crontab example runs '/usr/local/bin/diskusage.sh user@linuxconfig.sh' at 9.00 PM every Monday, Wednesday, Friday. Note: Using names for the week day and months is extension in some versions of crontab.

00 21 * * Mon,Wed,Fri /usr/local/bin/diskusage.sh user@linuxconfig.sh 

Crontab Example 6: This crontab example runs /usr/local/bin/diskusage.sh every 5 minutes during the 5 working days (Monday - Friday), every week and month.

*/5 * * * 1-5 /usr/local/bin/diskusage.sh 

Crontab Example 7: This crontab example runs /usr/local/bin/diskusage.sh every minute during the 4-th hour only in Sunday, every week and month. This is every minute from 0:00 till 0:59, then from 4:00 till 4:59, etc.

* */4 * * sun /usr/local/bin/diskusage.sh 

3. System wide cron scheduler

As a Linux administrator you can also use predefined cron directories:

/etc/cron.d /etc/cron.daily /etc/cron.hourly /etc/cron.monthly /etc/cron.weekly 

If root wishes to run backup.sh script once a week he will place backup.sh script into /etc/cron.weekly directory.

4. Cron Scheduler on user level

Every user can edit, view or remove his own crontab file. If the root user needs to change someone else's crontab file he must add '-u' option to specify the user name. To edit crontab file for user foobar we can use command:

# crontab -u foobar -e 

Remove foobar's crontab file:

# crontab -u foobar -r 

To view foobar's crontab content:

# crontab -u foobar -l 

Get FREE complimentary Linux Guides

The GNU/Linux Advanced Administration
The GNU/Linux systems have reached an important level of maturity, allowing to integrate them in almost any kind of work environment, from a desktop PC to the sever facilities of a big company.

In this ebook "The GNU/Linux Operating System", the main contents are related with system administration. You will learn how to install and configure several computer services, and how to optimize and synchronize the resources using GNU/Linux.

The topics covered in this 500+ page eBook include Linux network, server and data administration, Linux kernel, security, clustering, configuration, tuning, optimization, migration and coexistence with non-Linux systems. A must read for any serious Linux system admin.

A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.

You've probably heard about Linux, the free, open-source operating system that's been pushing up against Microsoft. It's way cheaper, faster, safer, and has a far bigger active community than Windows, so why aren't you on it? Don't worry, Makeuseof.com understands. Like many things, venturing off into a completely unknown world can seem rather scary, and also be pretty difficult in the beginning. It's while adapting to the unknown, that one needs a guiding, and caring hand. This guide will tell you all you need to know in 20 illustrated pages, helping you to take your first steps. Let your curiosity take you hostage and start discovering Linux today, with this manual as your guide! Don't let Makeuseof.com keep you any longer, and download the Newbie's Initiation to Linux. With this free guide you will also receive daily updates on new cool websites and programs in your email for free courtesy of MakeUseOf.

Linux from Scratch
Linux from Scratch describes the process of creating your own Linux system from scratch from an already installed Linux distribution, using nothing but the source code of software that you need.

This 318 page eBook provides readers with the background and instruction to design and build custom Linux systems. This eBook highlights the Linux from Scratch project and the benefits of using this system. Users can dictate all aspects of their system, including directory layout, script setup, and security. The resulting system will be compiled completely from the source code, and the user will be able to specify where, why, and how programs are installed. This eBook allows readers to fully customize Linux systems to their own needs and allows users more control over their system.

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)
Getting Started with Ubuntu 10.04 (Lucid Lynx) is a comprehensive beginners guide for the Ubuntu operating system; it features comprehensive guides, How Tos and information on anything you need to know after first installing Ubuntu.

Designed to be as user-friendly and easy to follow as possible, it should provide the first point of reference to any Ubuntu newcomer with lots of information. The manual has step by step instructions and includes lots of screenshots to show you how to do tasks. It also includes a Troubleshooting section to help you solve common Ubuntu problems quickly. Download this 160+ page manual today.

Comments (2)
  • imran

    exellent ....

  • Anil ML

    nice, really nice

Write comment
NOTE: To unsubscribe enter your email, select "do not dotify" with title: UNSUBSCRIBE and Send.
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
Security
Please input the anti-spam code that you can read in the image.