LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-09-2004, 10:33 PM   #1
akaash
LQ Newbie
 
Registered: Mar 2004
Location: Gujarat, India
Posts: 22

Rep: Reputation: 15
making an entry in crontab through code (perl)


I want to make an entry in system crontab file . How can i do that by perl code . Where is the cron situated ; which file?

HOw can i do that ?
 
Old 05-15-2004, 02:24 PM   #2
MarkBurke
LQ Newbie
 
Registered: Nov 2003
Location: Orange County, CA, USA
Distribution: aix, rhel, ubuntu
Posts: 24

Rep: Reputation: 0
Each user which has access to cron, will be able to run the command called crontab. Cron matches the first 5 fields of each crontab entry, and if the system date/time matches with the entry, then the command is executed. There is a seperate crontab for each user, including root.

As each user, you could run

crontab -e
The type vi commands to edit the crontab file. (i to insert, r to replace one char, x to delete a char, then type :q! to quit without save, or :wq to exit and save changes)

The crontab command is in this form:

Hour Minute DayOfMonth MonthOfYear DayOfWeek /someprogram args

Use * to indicate match any value of that field

Here's an example for sunday at 6am

6 0 * * 0 /bin/ls > /tmp/ls.txt

The 5th field is 0 for Sunday, fields are 0 through 6 for Sunday through Saturday. The day of month should have values from 1 to 31. You can do ranges like 1-31 or comma ranges like 0,5,10,15,20,25,30,35,40,45,50,55,60 (notice no spaces, because that moves to the next field) in the Minute field to run the command every 5 minutes.

Good luck,
I'm not sure on editing crontabs with perl, but the crontab file is an ascii file, but there are probably considerations to take into account with writing to the file, as cron constantly reads the file.

Probably you can do your crontab as a perl input file, and then run

crontab createdFile.txt

to install the new cron file (the entire thing)

Good luck again.
 
Old 05-17-2004, 03:36 AM   #3
pragti
LQ Newbie
 
Registered: Feb 2004
Posts: 16

Rep: Reputation: 0
Hi
the cron files are in the directory /var/spool/cron/(username)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
crontab entry? Master Fox Linux - Software 4 08-23-2005 01:20 PM
making a crontab xushi Slackware 5 05-08-2005 11:34 PM
crontab job entry notolerance Linux - Software 2 02-20-2005 02:40 PM
cronjob entry in crontab rockwell_001 Linux - General 2 06-30-2004 02:59 PM
crontab entry pilipk01 Linux - General 4 11-19-2003 07:53 PM


All times are GMT -5. The time now is 03:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration