1832648 Members
3204 Online
110043 Solutions
New Discussion

Cron Question

 
SOLVED
Go to solution
Hunki
Super Advisor

Cron Question

While updating crontab with crontab -e and then saving them with :wq ... the entries vanish after I disconnect for the shell ... this is happening for a regular non root user.
Have you guys faced this before...

Thanks
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Cron Question

Shalom,

Yes,

I've seen this happen when the users didn't have rights to his/her own file in /var/spool/cron

I've seen in when some other process overwrites all the cron files, perhaps a root cron job.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Jaime Bolanos Rojas.
Honored Contributor

Re: Cron Question

Hunki,

Please check to see if you have a /var/adm/cron/cron.allow and cron.deny,
check the permissions to see if the user has the rights to use cron.

Regards,

jaime.
Work hard when the need comes out.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Cron Question

You shouldn't be using crontab -e; as you have discovered it's a potentially dangerous shortcut. You should do it like this:

crontab -l > myfile
vi myfile
crontab < myfile

You then always have a backup file. However, the crontab command is always porentially dangerous because if you do this:
crontab
then crontab is waiting for stdin and will overwrite your existing entry with a null entry.

I suspect what is really happening is that you have users that are simply typing "crontab" without either a -e or -l argument.

In any event, I still suggest that you not use -e.
If it ain't broke, I can fix that.
MarkSyder
Honored Contributor

Re: Cron Question

Clay is giving you good advice, as e (edit) and r (remove) are next to each other on the keyboard.

My solution to this problem is to run a cron job that backs up the crontab file every Sunday. That way I can use crontab -e without worrying.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
OldSchool
Honored Contributor

Re: Cron Question


You shouldn't be using crontab -e; as you have discovered it's a potentially dangerous shortcut. You should do it like this:

crontab -l > myfile
vi myfile
crontab < myfile


That's the *only* way I edit them!