Home · News · Articles · Forum · Downloads · Search Your IP: 38.103.63.58 · Today: Wednesday, November 19, 2008
Main Menu
Home
News
Articles
- General
- Common Software
- Tips & Tricks
- Networking
- Multimedia
- Operation Systems
- Hardware
- Programming
- Security
- Configs
- CMS
Forum
Downloads
Gallery
Search
FAQ
Links
Ping us
Top 10 Article Posters
empty 37
nemo 3
scary 1
tashak 1
siluni 1
linuxGuru 1
Poll
What OS are you using?

Linux

*BSD

Solaris

Mac OS

Windows

Other

You must login to vote.
Setting up cron jobs using crontab
Setting up cron jobs using crontab.
This guide will show you how to setup a conjob using the crotab.

To install a cronjob, you will want to follow the following steps.

1. Enter username into following file:
user@UnixBox ~# vi /etc/cron.allow
Note: Be sure there is a blank line at the end of the file. You can always use a different text editor but this guide is showing it using vi.

2. Run crontab command:

- if you are logged in as root:
user@UnixBox ~# crontab -e -u username
Note: Here the username is the username owner of the cronjob.

- if you are logged in as the username that will be owner of the crontab:
user@UnixBox ~# crontab -e
Note: This can be executed as any user including the root if you are going to set a cronjob owned by the root.

The following is the syntax of the crontab:

[minute] [hour] [day of month] [month] [day of week] COMMAND
field allowed values
minute 0-59
hour 0-23
day of month 1-31
month 1-12
day of week 0-7 (0 or 7 is Sun)

You should prepend the COMMAND with nice. nice is a program that gives a given command a given priority. The default is 10. The range is from -20 to 20 with -20 being the highest priority.

Here is an example of running a nice'd command in the www/cgi-bin directory of a user every day at 11 PM (2300).

0 23 * * * nice ~/www/cgi-bin/command

~/ = current users home directory.. You should not have to, but you can also use ~username/ to further specify the given user. This is useful in case a process is launched by another user.

The "nice" option is used to limit the amount of resources that a cronjob can use. In some instances, you do not want to use the nice option. If the user is making calls to the perl library within their script, you would want to replace "nice" with "perl". This is difficult to determine unless you can recognize within their script that they are making calls to the perl library. If in doubt, just leave the cronjob to run as nice, and if the customer reports that their cronjob is not running properly, then change it to "perl".

For PHP scripts, you do not want to use nice. It is normally better to specify the path to the php binary before the path to the script. For example, replace "nice" with "/usr/bin/php".


Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Search

Enter words:


Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Users Online
Guests Online: 1
No Members Online
Registered: 55
Newest: Netherton216
Random Gallery Image
Linux's Hot
Linux's Hot
Wallpapers
Friends
DJs Place
Fresh Flash Games
Free Wallpapers
PHP Scripts
Levski
Flash Games
Improvements
Bookmark and Share
News Feeds
Article Feeds
Forum Feeds
Spam Poison
Valid CSS!
OSGuides.net 2007 - 2008 Creative Commons License.