Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


cgi perl script to edit a Cronfile

Posted on 2003-03-27
Medium Priority
Last Modified: 2012-06-27
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:)
Question by:manad

Expert Comment

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.

Expert Comment

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.
LVL 48

Accepted Solution

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

crontab crontabfile

Author Comment

ID: 8227424
Everyone, Thanks a lot for your help

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

564 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