HestonJames
Programmer
Morning All,
I'm pretty much a total novice when it comes to shell scripting but hopefully you guys will be able to best advise me on how to achieve this.
I'm working on putting together a postinst script for a .deb package that gets run after files have been placed in locations around the system to finalize the installation.
For this particular application I need to make an entry into the root users crontab file. Now, on its own this might not seem like a very tricky task, the file is located:
/var/spool/cron/crontabs/root
and looks something like this:
The line I want to add to this crontab looks something like this:
Now, the problem here lies in the fact that editing the file isnt actualy enough to install the modified crontab onto the system. Usualy, if doing this manualy you would open up the crontab using 'crontab -e' and make your changes, then when existing 'crontab -e' it installs the crontab for you.
Has anyone got any experiance of scripting crontab entries? Ideally I would also need a script which would reverse the entry and remove it, for uninstallation of the package.
I look forward to your suggestions guys,
Many thanks,
Heston
I'm pretty much a total novice when it comes to shell scripting but hopefully you guys will be able to best advise me on how to achieve this.
I'm working on putting together a postinst script for a .deb package that gets run after files have been placed in locations around the system to finalize the installation.
For this particular application I need to make an entry into the root users crontab file. Now, on its own this might not seem like a very tricky task, the file is located:
/var/spool/cron/crontabs/root
and looks something like this:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.Wk9Ybr/crontab installed on Fri Sep 12 10:47:41 2008)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# m h dom mon dow command
The line I want to add to this crontab looks something like this:
* * * * * python /myapp/myapp.py > /myapp/output 2>&1
Now, the problem here lies in the fact that editing the file isnt actualy enough to install the modified crontab onto the system. Usualy, if doing this manualy you would open up the crontab using 'crontab -e' and make your changes, then when existing 'crontab -e' it installs the crontab for you.
Has anyone got any experiance of scripting crontab entries? Ideally I would also need a script which would reverse the entry and remove it, for uninstallation of the package.
I look forward to your suggestions guys,
Many thanks,
Heston