?
Solved

cgi perl script to edit a Cronfile

Posted on 2003-03-27
4
Medium Priority
?
153 Views
Last Modified: 2012-06-27
Hi,
I am designing a web interface to edit the cron file. The user will enter the date month day etc and also the command to be run. What I need to know is how to edit the cron file. because if i open it like a normal text file and append to it, that wont work. The new information is there in the file but the job is not executed by the cron.

If I do crontab -e and edit it in VI editor it does work.
But i cannot do that from a cgi perl script

Is there any way to do this? Or any way I can schedule a cron job from a web interface?

thanks a lot:)
0
Comment
Question by:manad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 7

Expert Comment

by:rugdog
ID: 8219848
When you edit cron files with crontab -e, after you're done editing, a kill -HUP is issued to the crond, which refreshes its definitios of the various crontabs. When you manually edit crontabs, crond is not aware of the changes. So you should make  your web app to  HUP crond, but you'll need root privileges to do so.
0
 
LVL 2

Expert Comment

by:EarleAke
ID: 8220484
What you may want to do is to save the entry in a file then have a cron entry that periodically scans for anything in that file.  If something is found, add it to cron then HUP cron to get it to re-read it.  Depending on the version of the OS, you might be able to use something like this:

crontab -u username -l > /tmp/crontab.$$
echo "new command" >> /tmp/crontab .$$
crontab -u username /tmp/crontab.$$
rm /tmp/crontab.$$

I assume you want the user to run this new cron entry and not root.
0
 
LVL 48

Accepted Solution

by:
Tintin earned 340 total points
ID: 8221065
Once you've updated the crontab file, you just need to do

crontab crontabfile
0
 

Author Comment

by:manad
ID: 8227424
Everyone, Thanks a lot for your help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question