![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| range in hosts file | daveisme | AIX | 4 | 12-11-2008 11:42 AM |
| FTP file to different hosts | coolkid | Shell Programming and Scripting | 4 | 08-06-2008 06:41 PM |
| HOSTS File | cymerman | UNIX for Dummies Questions & Answers | 4 | 01-19-2007 12:26 PM |
| Using a script to modify the crontab | johnmsucpe | UNIX for Dummies Questions & Answers | 2 | 07-07-2005 02:44 PM |
| dns and hosts file | rmuhammad | IP Networking | 4 | 11-12-2003 02:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
crontab can also accept a file argument, just crontab filename, to replace the current cron table with the contents of filename. crontab - will read from standard input instead of a file. If you're appending something to a crontab, something like:
Code:
crontab -l > /root/cron-backup-$$
( cat /root/cron-backup-$$
echo "# Comment line for new entry"
echo "0 2 * * * /path/to/command argument" ) | crontab -
|
|
|||||
|
Hi Corona,
That's nice. I didn't know I could tell crontab to use another file. I don't have to append anything, actually, I have to modify (not add) a line in the middle of the crontab file, which I would do using sed/awk. So I can copy /var/spool/cron/crontabs/root (the current crontab file) to /var/spool/cron/crontabs/root.new and then run Code:
crontab /var/spool/cron/crontabs/root.new Am I right? I'm sorry, I just want to make sure I won't have to work all night long since alot of servers will be affected, hahaha. Thanks a lot! Brian |
|
||||
|
it would be best to avoid directly manipulating files in /var/spool/cron/crontabs/. create a backup with crontab -l as Corona688 suggested and then install the new one via the crontab command. Don't store the backup in /var/spool/cron/crontabs.
|
![]() |
| Bookmarks |
| Tags |
| awk, crontab, modify, sed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|