LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-25-2005, 12:25 PM   #1
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
editing crontab


hello,

I'm trying to change and add command to my crontab file. when i do:
Code:
crontab -e root
it takes me to a file so i can edit and change. Then i go and change something, save it, and quit. but when i go back into the crontab none of my setting were saved. How can i edit crontab so that my changes are saved?????? Also i like using vim better than vi, how do i change the VISUAL variable to vim permittedly???? so i don't have to type:
Code:
export VISUAL=vim
everytime.

thanks,.

djgerbavor3
 
Old 05-25-2005, 12:33 PM   #2
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
To change to vim add export VISUAL=vim somewhere in /etc/profile so changes will be global.

Strange, my cron is not working now... I'll check this out

Edit: This is strange, if I use vim as VISUAL it won't let me update but it will do if I use mcedit, I really don't get it. However I can use vim to edit crontab with my user without problems, the problem is with root.

Last edited by gbonvehi; 05-25-2005 at 12:50 PM.
 
Old 05-25-2005, 12:54 PM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I noticed this problem some time ago, as I fixed it with
editing /var/spool/cron/crontabs/root by hand, I didn't
search deeper...
I use VISUAL=vim too

Last edited by keefaz; 05-25-2005 at 12:55 PM.
 
Old 05-25-2005, 12:58 PM   #4
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
here are my exact steps, (am i doing something wrong)

i'm logged on as root
Code:
$>crontab -e root

# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
I change a few things and when i open crontab -e root everything i back to normal.

is there something i'm not doing right?


thanks,

djgerbavore
 
Old 05-25-2005, 01:02 PM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
No, this happen to me too, try instead :
Code:
$> vim /var/spool/cron/crontabs/root
 
Old 05-25-2005, 01:28 PM   #6
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
I've noticed this too as of late. mcedit works, but emacs doesn't.
current bug?
 
Old 05-25-2005, 01:33 PM   #7
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
ya, i noticed everytime i do crontab -e root it generates a new file in /var/spool/crontab directory.

so i just used the vim /var/spool/crontab/root and it works fine.

that is stranges, but not a big deal

thanks everyone,

djgerbavor3
 
Old 05-28-2005, 09:24 PM   #8
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
i found this in google groups because i was having the same problem:

-link to Google groups-

i hope that helps

also i found a good way of seeing whats going on it to attach strace to the crontab -e process i.e.

# ps ax

PID COMMAND
...
1234 crontab -e

# strace -p 1234


this will then show you what the system is doing. if you do it right the text you just entered in to the new crontab should show up in this output.

 
Old 05-28-2005, 10:00 PM   #9
killerbob
Member
 
Registered: Oct 2004
Location: Ottawa, ON
Distribution: Slackware
Posts: 662

Rep: Reputation: 31
About crontab, you seem to all be missing the part where /etc/cron.* directories exist. If you want to run something daily, hourly, weekly, monthly, etc. just create a script, make it executable, and link it in /etc/cron.X. No need to edit crontab, unless you want something that isn't already set up.

As for the "visual" variable, just put the export command mentionned above somewhere in /etc/profile.d.
 
Old 05-29-2005, 06:02 AM   #10
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
I for one do that, as I assume most here do as well.
The trouble is unless we use mcedit to edit crontab, the crontab is not saved.
 
Old 05-29-2005, 09:02 AM   #11
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
Try using VIM again but when you get to the program try issuing the command 'set compatible' first before you do the editing. ( you can issue this command by pressing : ( colon ) then typing set compatible and hitting enter )

once that has been done and the file saved and vim quit you should find that when issuing a crontab -l that the new bits you just put in are there.
 
Old 05-30-2005, 12:48 AM   #12
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
i haven't noticed this behavior at all...
but i'm not exporting a VISUAL
and i also haven't linked vi to vim.
 
Old 05-30-2005, 09:24 PM   #13
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Original Poster
Rep: Reputation: 30
Quote:
About crontab, you seem to all be missing the part where /etc/cron.* directories exist. If you want to run something daily, hourly, weekly, monthly, etc. just create a script, make it executable, and link it in /etc/cron.X. No need to edit crontab, unless you want something that isn't already set up.
killerbob, that works, but if you want to adjust the time and or add more flexibilty to crantabd you MUST edit teh crontab directly.

antken, thanks for the link and strace. straces is a very powerful program at times.

thanks,

djgeravor3

Last edited by djgerbavore; 05-30-2005 at 09:25 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
crontab x2??? killahsmurf Slackware 2 05-24-2005 10:53 PM
crontab mytinytown Linux - Newbie 3 02-17-2005 07:38 AM
crontab -e hoover93 Linux - Newbie 2 08-06-2004 04:05 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
crontab help usman Linux - General 7 08-06-2003 03:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration