![]() |
|
|
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 |
| commenting xml file lines | scorpio | Shell Programming and Scripting | 6 | 04-28-2009 09:29 PM |
| commenting | simmijaswal | Shell Programming and Scripting | 2 | 09-25-2008 11:52 AM |
| Commenting | dreams5617 | Shell Programming and Scripting | 6 | 04-16-2007 03:59 PM |
| Commenting lines | rolex.mp | UNIX for Dummies Questions & Answers | 2 | 02-21-2007 04:54 AM |
| commenting more then 1 line | ajayyadavmca | Shell Programming and Scripting | 3 | 12-14-2006 08:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Commenting contab from a script
Dear All, I have many cron entries and want to comment a particular cron entry from a script. Ex- Suppose I have the below cron entries: Code:
# DO NOT EDIT THIS FILE - edit the master and reinstall. #Cron entries for Jboss server 1 0 23 * * * /usr/bin/echo 0 23 * * * /usr/bin/asdg_count.sh 0 23 * * * /usr/bin/true 0 23 * * * /usr/bin/true I want to comment the entry for asdg_count.sh from my script I am using the below command: Code:
(echo ^[:g/watchdog/s/^/#/^[:wq!^M)|crontab -e >> temp.txt But the command is not working and I am getting the console message as : Code:
Vim: Warning: Output is not to a terminal Vim: Warning: Input is not from a terminal crontab: "vi" exited with status 1 and the message in temp.txt is : Code:
-- Ip/crontab.XXXXOKeTQL" 7L, 305C Vim: Error reading input, exiting... Vim: preserving files... Vim: Finished. Please help on commenting the cron from the script. Thanks AK Last edited by Franklin52; 10-02-2009 at 04:33 AM.. Reason: Please use code tags! |
|
||||
|
One way which may help you.,
1. Backup the crontab as crontab -l >> tmpfile.txt 2. Use sed with -i option to substitute. 3. and then remove all crontab. crontab -r 4. install the new file as crontab tmpfile.txt It will work best for you.... instead of trying to do the edition with vim. Also, note that, if some body else edits that crontab at the same time then you will end up in mess.. |
|
||||
|
crontab -e, complete or not, is wrong! crontab -l was mentioned, though. I would be cautious of automating anything with the crontab file without taking a backup first. Code:
crontab -l | tee crontab.bak | sed '/asdg_count.sh/ s/^/#/' | crontab - Last edited by scottn; 10-02-2009 at 04:03 PM.. Reason: good spot, methyl.... added closing apostrophe |
|
||||
|
avishek007 the example you post is looking for a line in crontab containing the word "watchdog" not "asdg_count.sh". There is a minor typo in cfajohnson's post (missing quote) which has been carried forward into the next two posts. Perhaps that is the problem? Code:
crontab -l | sed '/asdg_count.sh/ s/^/#/' | crontab - I would always advise copying crontab to a safe area before editing the file. The rest really depends on local rules. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|