- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- crontab entry automation
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2006 03:08 AM
тАО05-02-2006 03:08 AM
crontab entry automation
I need to automate updating the cron entry in my server.
Is there any way in which I can add an entry to the end of the crontab without actually opening the cron file.
-Pat
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2006 03:13 AM
тАО05-02-2006 03:13 AM
Re: crontab entry automation
echo "5 4 * * 1 /dir/command_to_run" >> /var/spool/cron/crontabs/root
If you do that, you will then have to stop and restart the cron daemon for the change to take effect. Otherwise your job will not run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2006 03:13 AM
тАО05-02-2006 03:13 AM
Re: crontab entry automation
Yes,
You can echo directly to /var/spool/cron/crontab.root
This is not recommended by me but quite possible
echo "10 16 * * * /usr/local/bin/job 2>&1" >> /var/spool/cron/crontab.root
I don't do this, and you may need to start and stop the cron daemon.
Really the best way to go is to edit the file or a copy of he file.
Some will not run crontab -e.
I once had an operator come to me with apologies because a PC power supply failure wile editing a regular users crontab file caused it to be empty.
It was restored from backup, but messing with the file directly does risk that outcome.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2006 03:16 AM
тАО05-02-2006 03:16 AM
Re: crontab entry automation
if you want a change without changing - that is not possible :-) .
If you mean a 'batch change' without opening an editor:
crontab -l >/tmp/crontab.save
cp /tmp/crontab.save /tmp/crontab.new
print '1 2 3 4 * new-cronjob' >>/tmp/crontab.new
crontab /tmp/crontab.new
You have '/tmp/crontab.save' as a backup if something goes wrong ...
Perhaps you better check if 'new-cronjob' does not already exists.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2006 03:32 AM
тАО05-02-2006 03:32 AM
Re: crontab entry automation
Something like this should work:
#!/usr/bin/sh
typeset TDIR=${TMPDIR:-/var/tmp}
typeset C1=${TDIR}/X${$}_1.cron
crontab -l > ${C1}
echo "15 23 * * * /new/command/goes_here # comment for new command" >> ${C1}
crontab < ${C1}
rm -f ${C1}
You should add a little error checking and probably get the new entry from the command line but that's the gist of it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2006 04:39 AM
тАО05-02-2006 04:39 AM
Re: crontab entry automation
Another way to do it is to use dsau(Distributed Systems Administration Utility) if you have several servers. If you just have one it's not a good idea and should be a waste of time to configure it.
http://docs.hp.com/en/B2355-90950/ch03s04.html
If you can't use it directly due to some OS restriction, go directly to the site of the GNU product cfengine(http://www.cfengine.org/). This product deserve to work on it,it should verify and edit (if it need) the cron for you and restart or not the daemon. Cfengine can do much more, take a look.
Hope this helps
Kenavo
Pat