Can we edit crontab using a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can we edit crontab using a shell script
# 1  
Old 03-31-2005
Power Can we edit crontab using a shell script

Hi,


Can some one tell me if we can configure the jobs in crontab using a shell script.

I know it can be done easily by using "crontab -e", but i just want to know whether we can add a job into the crontab using a shell script.

If it can be done, plz suggest the procedure to do it.
If it cannot be done then why(reason)?

thanks
# 2  
Old 03-31-2005
IF you are using your own cron script file as,

crontab -f <filename>

so that installation and deinstallation will be based on that file. Else psuedo-random file will be used for this operation.

HTH.
# 3  
Old 03-31-2005
have your script ...

a. crontab -l > $tmpfile
b. edit $tmpfile
c. crontab $tmpfile
d. rm $tmpfile
# 4  
Old 03-31-2005
Thanks a lot...... Smilie That made my life soooo easy......
# 5  
Old 06-16-2009
Does one then have to restart cron daemon

Hi there,

First post on these forums can't believe it actually as I always end up browsing them... anyway...
Sorry to bounce a 4yo thread but it still has relevance.

I am actually doing exactly what is described in this thread but I have one further question and that is:

Do I then have to restart cron after making the change to have it take effect?

My guess is that since you are still using the actual crontab command, not just directly editing the cron file, then no, as I imagine it still runs the install / restart itself, as if you have just run a crontab -e?
Is this correct?

Any help would be much appreciated,

Thanks,
# 6  
Old 06-16-2009
"crontab -e username" edits the live crontab and notifies cron of the change. There is no need to restart cron.
The technique suggested by "Just Ice" can be improved by copying the crontab twice to different names. You then have the original crontab saved if something goes wrong and a baseline file to "diff" against.
# 7  
Old 06-16-2009
Okay, kool...

Thanks for your help Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't edit my Crontab

Hi, I m setting up my crontab for the very first time. I m a non-root user and this is linux $ export EDITOR=vi $ crontab -e no crontab for user1 - using an empty one crontab: installing new crontab "/tmp/crontab.uW0JNx":1: bad command errors in crontab file, can't install. Do you want... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Homework & Coursework Questions

Edit the file in shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to automate hadoop installation procedure using shell script. It involves go to perticular directory... (3 Replies)
Discussion started by: Abdul Navaz
3 Replies

3. Shell Programming and Scripting

shell script to edit a file

i have a file called number which contains data as 1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 needed a shell script to print the output as 1 7 7 1 4 and (2 Replies)
Discussion started by: jacky29
2 Replies

4. Shell Programming and Scripting

Shell script to edit a file

Hello, I have a big file in wich I would like to rename inside this exactly the string '_ME' and not rename in case we have 'ABC_MELANGE'. Is there a way to do it by using a shell script? Any tip will be apreciated. The file is like described bellow, after using command more filename : ... (3 Replies)
Discussion started by: Titas
3 Replies

5. Shell Programming and Scripting

edit columns in unix shell script

i have a file which if you will open as xls will yield something like this: Column1 Column2 Column3 ABC CDE EFG GHI IJK KLM MNO OPQ QRS what i want to need is to have this kind of results: Column1 ABC CDE EFG GHI IJK ... (10 Replies)
Discussion started by: kingpeejay
10 Replies

6. Shell Programming and Scripting

Need help in a shell script to edit a tablespace creation script.

Hi, CREATE TABLESPACE aps_blob_large01 DATAFILE '/c2r6u13/u03/oradata/qnoldv01/aps_blob_large0101.dbf' SIZE X 270532608 REUSE DEFAULT STORAGE (INITIAL 134217728 NEXT... (2 Replies)
Discussion started by: rparavastu
2 Replies

7. Shell Programming and Scripting

shell script to edit the content of a file

Hi I need some help using shell script to edit a file. My original file has the following format: /txt/email/myemail.txt /txt/email/myemail2.txt /pdf/email/myemail.pdf /pdf/email/myemail2.pdf /doc/email/myemail.doc /doc/email/myemail2.doc I need to read each line. If the path is... (3 Replies)
Discussion started by: tiger99
3 Replies

8. UNIX for Dummies Questions & Answers

Edit Crontab

Hi I am new to Unix and would like some assistance. I need to edit the crontab file so that a script is set to run at 3:00 am each day. When I telnet to the sun server and type crontab -e a black screen appears and I am unable to make any changes. Could you advice on what is needed to... (11 Replies)
Discussion started by: juliet
11 Replies

9. Shell Programming and Scripting

edit crontab without -e

hi i need to change crontab settings as minute,hour,day of month,month year,day of week certain times. for that i need to go as crontab -e. i want to avoid that as its creating many problems in mysystem. so here i m planning/trying to write a script that will update the settings in crontab... (8 Replies)
Discussion started by: d_swapneel14
8 Replies

10. UNIX for Dummies Questions & Answers

Can't edit crontab

I saw a post on here a while back describing how to edit a crontab file when I'm not able to edit it via crontab -e. Currently, if I try to do a crontab -e, it just comes back with: # crontab -e 7987 <and then it just hangs there FOREVER> If I do a crontab -l, it shows me all of the... (1 Reply)
Discussion started by: FredSmith
1 Replies
Login or Register to Ask a Question