How to edit a crontab file within a script when not root
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > How to edit a crontab file within a script when not root




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How to edit a crontab file within a script when not root  
Tom


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-25-04 05:34 PM

I am looking for an automated way to edit a crontab, as root I can use sed
and modify the file.  As a non root user I am not allowed to edit the file.

IS there a way to create a shell script that my userid can execute, that
will have root privileges to modify the command.  I want to send this to all
the workstations when installing some software?

Thansk







[ Post a follow-up to this message ]



    Re: How to edit a crontab file within a script when not root  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-25-04 06:34 PM

On Sun, 25 Apr 2004 at 16:19 GMT, Tom wrote:
> I am looking for an automated way to edit a crontab, as root I can use sed
> and modify the file.  As a non root user I am not allowed to edit the file
.
>
> IS there a way to create a shell script that my userid can execute, that
> will have root privileges to modify the command.  I want to send this to a
ll
> the workstations when installing some software?

You don't need root privileges. Just edit a file and use crontab
to install it:

crontab -l > $HOME/crontab
fix_up $HOME/crontab ## script to edit crontab file
crontab $HOME/crontab

--
Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
 ========================================
===========================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License





[ Post a follow-up to this message ]



    Re: How to edit a crontab file within a script when not root  
Randal L. Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-25-04 06:34 PM

>>>>> "Tom" == Tom  <tcarmich@nortelnetworks.com> writes:

Tom> I am looking for an automated way to edit a crontab, as root I can use 
sed
Tom> and modify the file.  As a non root user I am not allowed to edit the f
ile.

Tom> IS there a way to create a shell script that my userid can execute, tha
t
Tom> will have root privileges to modify the command.  I want to send this t
o all
Tom> the workstations when installing some software?

If this is vixie cron, just set an env var to your script:

EDITOR=/your/script crontab -e

/your/script will get invoked with /tmp/some-name containing the crontab.
Just rewrite the file, and exit clean.  If the crontab is syntax-valid,
then it gets installed as the new crontab.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment PERL training
!





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:33 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register