1832622 Members
2482 Online
110043 Solutions
New Discussion

Re: crontab edit

 
SOLVED
Go to solution
Petr Simik
Occasional Contributor

crontab edit

I changed cron this way:
vi /var/spool/cron/crontab/user

this change has no affect and system has in memory old cron file.
I tried
kill -1 (/usr/sbin/cron)
but this is not that proces becouse also without affect to system.

Which process is responsible for running a cron and what I have to do to reread new cron.

I understand the common way crontab -e , l ...
but for some purposes I would like to understand this way.

Thanks.
6 REPLIES 6
T G Manikandan
Honored Contributor
Solution

Re: crontab edit

For a normal user to use crontab you should have entry in the cron.allow in /var/adm/cron.

You should edit the crontab file using
EDITOR=vi;export EDITOR
crontab -e

you can restart cron using

/sbin/init.d/cron stop
/sbin/init.d/cron start.


Thanks
Ravi_8
Honored Contributor

Re: crontab edit

Hi,Peter

#crontab -e username, creates a crontab file for that user. The user must ahve a entry in
/var/adm/cron/cron.allow file.

you can restart cron using

/sbin/init.d/cron stop
/sbin/init.d/cron start.
never give up
Khalid A. Al-Tayaran
Valued Contributor

Re: crontab edit


Hi,

- First, check your current crontab file:
crontab -l > cronfile

- then make changes to it with vi

- submit the new file to crontab:
crontab cronfile


Good luck........
Darrell Allen
Honored Contributor

Re: crontab edit

Hi,

While "crontab -e" is a perfectly acceptable way to edit your crontab, I prefer to make changes to a copy of my crontab then implement it. Here's how:

crontab -l >cron.file
vi cron.darrell
(make my changes)
crontab cron.file

I just find this safer.

And as you have discovered, never directly edit /var/spool/cron/crontabs files directly.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Darrell Allen
Honored Contributor

Re: crontab edit

Weird. I didn't see Khalid's reply just a few minutes ago when I started my reply even though it was posted long before I replied. Otherwise I'd have simply affirmed his approach.

Anyway, I made a typo in my example. It should be:

crontab -l >cron.file
vi cron.file
(make my changes)
crontab cron.file

No points please.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Gerald Virden
Advisor

Re: crontab edit

Petr,

My experience has been that crontab -e works fine. However, I edited a cron file this way once and the cron file disappeared. Fortunately, I had a copy in my directory. Bill Hassell has suggested in his sysadm training to edit a copy with vi and then run the file using crontab "filename".