Unix Technical Forum

crontab for root

This is a discussion on crontab for root within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> hi all , I got one problem I want to write "1" into a file every three hours . ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-19-2008, 07:25 AM
Rakotomandimby
 
Posts: n/a
Default crontab for root

hi all ,
I got one problem
I want to write "1" into a file every three hours .
I want to use cron , beeing root ( using the root crontab).
What i do is :
-log in being root ,
-type "crontab -e root"
-the file opened is not blank , there already is the hourly , dayly,
monthly ... stuff into it ,
- i append this :
0 *3/ * * * echo 1 > /file_to_write_to
- i save + close the editor
- if i type "crontab -l root" , then the line i appended is not present .
- if a wait , the job is not done .


- if i directly edit /var/spool/cron/crontabs/root , by appending my line
the line is then shown when i call crontab -l root .
but was it the cleanest way ?

- if i make the same procedure but with an user , all is OK . i dont have to
edit /var/spool/cron/crontabs/$user

what did i miss ?

I run SLack 9.1 .

Tnaks in advance for you help .

--
http://mrakotom.free.fr

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-19-2008, 07:25 AM
Mark Hill
 
Posts: n/a
Default Re: crontab for root

On Sun, 11 Jan 2004 13:08:45 +0100,
Rakotomandimby <mrakotom@free.fr> wrote:

> I want to use cron , beeing root ( using the root crontab).
> What i do is :
> -log in being root ,
> -type "crontab -e root"
> -the file opened is not blank , there already is the hourly , dayly,
> monthly ... stuff into it ,
> - i append this :
> 0 *3/ * * * echo 1 > /file_to_write_to


I think that should be
0 */3 * * * echo 1 > /file_to_write_to

> - i save + close the editor
> - if i type "crontab -l root" , then the line i appended is not present .
> - if a wait , the job is not done .


Are you using vim? If so, you might need to add ':set compatible' to
make your crontab entry stick. The archives have more info about this,
IIRC.


--
Mark Hill <usenet@mark.ukfsn.org> (Yahoo address not read)
GPG KeyID: 4A3B58AC
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 07:25 AM
Rakotomandimby
 
Posts: n/a
Default Re: crontab for root

Mark Hill wrote:

>> - i append this :
>> 0 *3/ * * * echo 1 > /file_to_write_to

>
> I think that should be
> 0 */3 * * * echo 1 > /file_to_write_to


Yes it is ...it was just a typing error when copying it here...

> Are you using vim? If so, you might need to add ':set compatible' to
> make your crontab entry stick. The archives have more info about this,
> IIRC.


To avoid any troll-like thing , i did not mention my editor , but i use
Emacs to do it .

--
http://mrakotom.free.fr

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 07:25 AM
Jazzcat
 
Posts: n/a
Default Re: crontab for root

On Sun, 11 Jan 2004 13:08:45 +0100, Rakotomandimby wrote:

> hi all ,
> I got one problem
> I want to write "1" into a file every three hours .
> I want to use cron , beeing root ( using the root crontab).
> What i do is :
> -log in being root ,
> -type "crontab -e root"
> -the file opened is not blank , there already is the hourly , dayly,
> monthly ... stuff into it ,
> - i append this :
> 0 *3/ * * * echo 1 > /file_to_write_to
> - i save + close the editor
> - if i type "crontab -l root" , then the line i appended is not present .
> - if a wait , the job is not done .
>
>
> - if i directly edit /var/spool/cron/crontabs/root , by appending my line
> the line is then shown when i call crontab -l root .
> but was it the cleanest way ?
>
> - if i make the same procedure but with an user , all is OK . i dont have to
> edit /var/spool/cron/crontabs/$user
>
> what did i miss ?
>
> I run SLack 9.1 .
>
> Tnaks in advance for you help .


Just curious, are you using vim or elvis as your editor?

I also have the exact same problem and it seems to be related to vim and
to .vimrc

By default in slackware 9.1 /usr/bin/vi is a link to /usr/bin/elvis, which
creates no problem in editing root's crontab with 'crontab -e root'. Now I
don't use elvis so my /usr/bin/vi links to /usr/bin/vim instead, and again
there is no problem using 'crontab -e root'.

However, when I create a .vimrc file in /root, even if this file has
nothing but comments in it, 'crontab -e root' suddenly stops registering
changes to /var/spool/cron/crontabs/root, even though the temporary file
created by crontab /var/spool/cron/crontab.XXX DOES register the changes I
make. All the permissions seem to be ok, and I've run into this problem in
every slack box I've worked on.

I can still edit root's crontab directly of course, and every other user
can edit their crontabs with 'crontab -e' using vim and the exact same
..vimrc in their home directories.

It's simple enough to reproduce this problem:
(as root)

rm /usr/bin/vi
ln -s /usr/bin/vim /usr/bin/vi
touch ~/.vimrc
crontab -e (and any changes won't be made to /var/spool/cron/crontabs/root)

Any ideas?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-19-2008, 07:25 AM
Rakotomandimby
 
Posts: n/a
Default Re: crontab for root

Jazzcat wrote:
> Any ideas?


I found that :
http://braille.uwo.ca/pipermail/spea...il/020328.html

I think root's crontab is not editable ( according to the first line of this
post .. )

I'm searching further ...
--
http://mrakotom.free.fr

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-19-2008, 07:25 AM
Jazzcat
 
Posts: n/a
Default Re: crontab for root

On Sun, 11 Jan 2004 13:28:47 +0000, Mark Hill wrote:

> On Sun, 11 Jan 2004 13:08:45 +0100,
> Rakotomandimby <mrakotom@free.fr> wrote:
>
>> I want to use cron , beeing root ( using the root crontab).
>> What i do is :
>> -log in being root ,
>> -type "crontab -e root"
>> -the file opened is not blank , there already is the hourly , dayly,
>> monthly ... stuff into it ,
>> - i append this :
>> 0 *3/ * * * echo 1 > /file_to_write_to

>
> I think that should be
> 0 */3 * * * echo 1 > /file_to_write_to
>
>> - i save + close the editor
>> - if i type "crontab -l root" , then the line i appended is not present .
>> - if a wait , the job is not done .

>
> Are you using vim? If so, you might need to add ':set compatible' to
> make your crontab entry stick. The archives have more info about this,
> IIRC.


Just made a post to this thread. You're right setting vim to compatability
mode fixes this. Doh!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-19-2008, 07:26 AM
Henrik Carlqvist
 
Posts: n/a
Default Re: crontab for root

"Rakotomandimby" <mrakotom@free.fr> wrote:
>> 0 */3 * * * echo 1 > /file_to_write_to

>
> Yes it is ...it was just a typing error when copying it here...


> To avoid any troll-like thing , i did not mention my editor , but i use
> Emacs to do it .


Maybe it would help to do the following:

crontab -l > /tmp/crontab.root
emacs /tmp/crontab.root
crontab /tmp/crontab.root

I used to do it that way with Slackware 8. So far with Slackware 9.1 I
have only added scripts to /etc/cron.*

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc2(at)uthyres.com Examples of addresses which go to spammers:
synpunkt@svartalistan.com info@emailpromo.biz root@localhost
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com