- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Editing crontab files the wrong way...
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
Forums
Discussions
Discussions
Discussions
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
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
08-07-2003 11:46 AM
08-07-2003 11:46 AM
I believe I goofed when I tried to edit the crontab files. I edited the files directly with vi...and when poking around this site and executing a search on 'edit crontabs' I came across some interesting topics, one which states that a user should do this:
crontab -l > cron.file
vi cron.file
(make the changes you want)
crontab cron.file
I have a question, since I edited the crontab file directly (as sudo root), and want to undo my changes, do I just vi to the crontab file and remove what changes I made?
Another question, the procedure I have indicated above, this simply takes the crontab file contents, and puts in another file (or renames it), and makes the necessary changes, and makes this recently renamed file the crontab file. What is wrong with editing the ctonrab file directly, if you make a coly of the file and append .old to the file?
Should I just try to use crontab -e?
Please mention if I should remove the edits I made to the file via vi directly.
By the way, I was going to set up the system to reboot on a weekly basis, and this never happened and I believe it is because I did not edit the crontab file correctly, even though I set up the parameters right.
Thanks for your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 11:53 AM
08-07-2003 11:53 AM
SolutionI never use 'crontab -e'. Instead I use the sequence you described:
# crontab -l > mycrontab
# vi mycrontab
# crontab mycrontab
The rationale for *not* editing directly (with '-e' is that if I bungle the edit and exit 'vi' the copy (overwrite) of the crontab entry occurs anyway -- not very desirable.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:00 PM
08-07-2003 12:00 PM
Re: Editing crontab files the wrong way...
Thanks. Ok...now do I need to vi the crontab file directly and remove what I put in the crontab. That is...undo my errors?
I figured I would just use the procedure I indicated in the post, but would my original edit show up?
Also, the server never rebooted after I edited the crontab file directoyl. Do you think that it is because of the wrong way I edited the crontab file?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:02 PM
08-07-2003 12:02 PM
Re: Editing crontab files the wrong way...
You're choices for undoing what you've done are:
1) vi it and undo, as you said.
2) restore from backup.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:04 PM
08-07-2003 12:04 PM
Re: Editing crontab files the wrong way...
In my HP student workbook (HP-UX System Administration I) it says that " files in /var/spool/cron/crontabs should never be edited directly or removed because doing so can leave the cron daemon in an idefined state" (??)
I guess you need kill and restart the cron daemon with these two commands:
/sbin/init.d/cron stop
/sbin/init.d/cron start
and resubmit your jobs correctly.
Elena.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:06 PM
08-07-2003 12:06 PM
Re: Editing crontab files the wrong way...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:08 PM
08-07-2003 12:08 PM
Re: Editing crontab files the wrong way...
Alternatively, you can do the crontab -l > file routine and use *view* to edit. View has the inherant benefit of being explicitly read-only. This means you have to do wq! to commit any changes before exiting the editor.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:14 PM
08-07-2003 12:14 PM
Re: Editing crontab files the wrong way...
echo $EDITOR
Chances are its the default value, vi.
Which is what you're using, right?
The only difference that I'm aware of with crontab is the use of csh instead of POSIX or korn.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:21 PM
08-07-2003 12:21 PM
Re: Editing crontab files the wrong way...
crontab -l > cron.file
vi cron.file
crontab cron.file
I just hope when I edit the file directly via vi, it does not screw anything up or make it worse, which is why I inquired.
Thank you folks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:27 PM
08-07-2003 12:27 PM
Re: Editing crontab files the wrong way...
I'd use the procedures listed above to stop cron, look for any other cron processes. assuming none, recreate the cron file, put it back, as described, then start cron.
Put a test job in as well, that runs soon after you anticapate being finished.
10 * * * * * mailx me@.com < testfile
make sure you get the mail, and only one of them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:30 PM
08-07-2003 12:30 PM
Re: Editing crontab files the wrong way...
" make sure you get only one mail" when my example will give you one every hour forever.
sorry :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 12:33 PM
08-07-2003 12:33 PM
Re: Editing crontab files the wrong way...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 01:06 PM
08-07-2003 01:06 PM
Re: Editing crontab files the wrong way...
Clay, Are there any risks to stopping and starting cron from init.d? ( I suppose we could prevent a job from running if it's scheduled time passes while we're moving files around)
Any others?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2003 01:03 AM
08-08-2003 01:03 AM
Re: Editing crontab files the wrong way...
Just a couple of points from your original question.
1) If you append .old to a copy of the crontab file it may cause problems. Any files in that directory are assumed to be valid crontab files named after a specific user, hence I believe cron will try to run the .old file and will look through /etc/passwd to find the owner (which It will never find.) This will cause complications if you ever try to trust the system for example.
2) You don't need to remove the edits you made directly to a file if you've already resubmitted using crontab
regards,
Darren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2003 09:14 AM
08-08-2003 09:14 AM
Re: Editing crontab files the wrong way...
cd /var/spool/cron
crontab -l>cronfile
vi cronfile (then saved with wq!)
crontab cronfile
Then I got this line showing up
"commands will be executed using /usr/bin/sh"
What does the previous line mean?
Also, since one poster said that if you names the file .old then it will be read when cron executes. Well, I now have the file 'cronfile' listed in /var/spool/cron, should I then remove the cronfile now or leave it there? I don't think this should be in /var/spool/cron.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2003 10:08 AM
08-08-2003 10:08 AM
Re: Editing crontab files the wrong way...
The line about commands being executed by /usr/bin/sh means that your cron jobs will be running under the POSIX shell. If you wrote and tested your scripts using another shell [Korn, csh, etc.] you might need to try them again using the POSIX shell. This is just a reminder message.
As for the file in /var/spool/cron, it should be ok. The cron daemon looks for the files in /var/spool/cron/crontabs.
JP