Linux Runlevels

Written by Vinu Thomas


Linux systems today generally use eight runlevels. Runlevels define what services or processes should be running onrepparttar system. The init process can runrepparttar 107745 system in one of eight runlevels. The system runs only one ofrepparttar 107746 eight runlevels at a time. The main runlevels are from 0 – 6. Here's what each runlevel is for

Runlevel 0: Halt System - To shutdownrepparttar 107747 system Runlevel 1: Single user mode Runlevel 2: Basic multi user mode without NFS Runlevel 3: Full multi user mode (text based) Runlevel 4: unused Runlevel 5: Multi user mode with Graphical User Interface Runlevel 6: Reboot System

Runlevels 1 and 2 are generally used for debugging purposed only, and are not used during normal operations. Most desktop linux distributions boot into runlevel 5, which starts uprepparttar 107748 Graphical Login Prompt. This allowsrepparttar 107749 user to userepparttar 107750 system with X-Windows server enabled. Most servers boot into runlevel 3, which startsrepparttar 107751 text based login prompt.

Linux runlevels can be changed onrepparttar 107752 fly usingrepparttar 107753 init tool. If you want to switch from text based operations torepparttar 107754 Graphical Interface, you just have to type in 'telinit 5' inrepparttar 107755 root prompt. This will bring uprepparttar 107756 Graphical Interface in your system.

Automating Tasks in Linux using Cron

Written by Vinu Thomas


Linux has a powerful task scheduler called Cron. Cron will allow you to run commands automatically at times specified by you. Cron is similar torepparttar task scheduler you find in Windows. To keep track ofrepparttar 107744 schedules and tasks it has to run, Cron requires a file called Crontab (CRON TABle). Allrepparttar 107745 Cron schedules and tasks should be stored in this table. The Crontab files cannot be directly edited. You can add or delete entries inrepparttar 107746 crontab file usingrepparttar 107747 crontab command.

What's Cron and Crontab ?

You must be wondering whatrepparttar 107748 difference between cron and crontab or wether they arerepparttar 107749 same. Cron is a process or program which wakes up every minute and looks for jobs it has to execute at that moment. Crontab isrepparttar 107750 list of jobs and times at which they have to execute.

Crontab Format:

Each entry in Crontab has at least 6 fields separated by a single space. Field 1 Minute Range of Values : 0-59 Field 2 Hour Range of Values : 0-23 Field 3 Day Range of Values : 1-31 Field 4 Month Range of Values : 1-12 Field 5 Day of week Range of Values : 0-6 (Sunday being 0) Field 6 Command to Execute

Now let's see how to make a crontab entry. Let's say you want to run a script backup.sh every day at 6:00pm.The entry would look like this:

0 18 * * * /home/user/backup.sh

The asterisk (*) is used to indicate that every instance of repparttar 107751 particular time period will be used (i.e. every hour, every weekday, etc.). I've used to full path torepparttar 107752 script /home/user/backup.sh instead of just using backup.sh. This is because cron runs as root, you should fully qualify your path names to any scripts that will be run. Let's see some more examples :

* Let's runrepparttar 107753 script printinvoices.sh every sunday at 12:45pm.

45 12 * * 0 /home/account/printinvoices.sh

* How about clearaccount.sh every month beginning at 1:32am ?

Cont'd on page 2 ==>
 
ImproveHomeLife.com © 2005
Terms of Use