Using a script to modify the crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using a script to modify the crontab
# 1  
Old 07-07-2005
Using a script to modify the crontab

I want to add one line to the end of my crontab using a script.
I have tried piping in the editor commands, but I can't get it to work.

crontab -e user << EX
$a
This is the text I want to add.
.
wq
EX

This doesn't work. Is there an easier way to do this?
# 2  
Old 07-07-2005
It is not necessary to use crontab -e to edit crontabs. You can directly do this:

echo "<entire_line_that_is_required_including_the_timings_and_commands>" >> /var/spool/cron/<crontab_file>

You will have to give the cron daemon a HUP signal after this. So if you are not someone who has root access, you will have to find someone that does.
# 3  
Old 07-07-2005
I do not see anything in the HP-UX nor SunOS cron man page to suggest that cron responds to SIGHUP. Looking at Sun's source code for cron (Thanks, Sun!! Smilie ), I see only:
(void) signal(SIGHUP, SIG_IGN);
You typically need to restart cron after doing something like this.

I have to say that I recommend the use of the crontab command, even for root. And it's easy enough:

crontab -l > oldcrontab
cp oldcrontab newcrontab
echo "$newline" >> newcrontab
crontab < newcrontab
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modify python script

How can I modify this so it uses Seamonkey and goes to Yahoo Advanced Web Search #!/usr/bin/python3 import os import urllib google = os.popen('zenity --entry --text="Enter what you want to google: " --title="google.py"').read() google = urllib.quote(google) os.system('firefox... (8 Replies)
Discussion started by: drew77
8 Replies

2. UNIX for Dummies Questions & Answers

Modify hour crontab UNIX

Hello, I wish to modify the day of launch of a "batch" in the crontab on several servers with awk or sed. Can you help me ? Beforehand thank you 00 18 * * 1 /box/Pra/bin/systeme_reverse.ksh -s >/dev/null 2>&1 (7 Replies)
Discussion started by: khalidou13
7 Replies

3. Shell Programming and Scripting

Modify the file by script

Hi All, I have an input file like below, 6984 1225 6989 1220 6994 1214 ... (3 Replies)
Discussion started by: Indra2011
3 Replies

4. Shell Programming and Scripting

Modify sed script

I'm trying to take out strings from log files and add them to a csv. For example, in the directory now, there are 2 log files. I get the following results: sed -e '/custodian/b' -e '/packaged by/b' -e '/package name/b' -e '/Total Data (MB) Read/b' -e '/Begin Time/b' -e d * packaged by =... (10 Replies)
Discussion started by: chipperuga
10 Replies

5. Shell Programming and Scripting

Help me to modify my script in stdout

please help me to modify my script #! /bin/bash while read line do echo "$line" >>/tmp/result && mysql -ss -e "use $line; select count(*) from users where type='admin' and deleted = 0;" > /tmp/result; done < /tmp/db_data cat result alan_hardwsdefs 2 bgrmods 2 claudiatdsefs 1... (2 Replies)
Discussion started by: unimaxlin
2 Replies

6. Shell Programming and Scripting

how can I modify this script.

hello forum members, I have a script which is used find the Uname and passwords and redirects into a output.txt file.I hardcoded a string "ciadev" but iwant search two more strings also "absdev" and "absprod" So modify this script please. I am lookinmg forward from you, please find the below... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

7. Shell Programming and Scripting

Sed or Awk for modify hour in a crontab AIX

Hi, I want to modifiy the hour in the crontab AIX 5.3 for this line: Input: 00 22 * * * /outillage/script_exploit/bin/SavOffline.ksh > /dev/null 2>&1 Output: 30 20 * * * /outillage/script_exploit/bin/SavOffline.ksh > /dev/null 2>&1 With the awk or sed function through a ssh -q... (1 Reply)
Discussion started by: khalidou13
1 Replies

8. Shell Programming and Scripting

Modify crontab file on many hosts...

Hi everyone taking a second to read this :D, I need to modify a line from the root crontab file... Usually, if I need to do this I use the crontab -e, which opens up the file with Vi, then I edit it and there's no problem. Now, I need to do this but on many servers at the same time... Like in... (3 Replies)
Discussion started by: Casey
3 Replies

9. Shell Programming and Scripting

Please help to modify my script

Hi, I have a script which connect to ATM's and pull two files from the ATM. The which i try to pull is like PIC20085200001*.JPG First 7 digit consist of year montn and date as well After todays execution i want to change the date to next date I add few lines in the script but it is not... (6 Replies)
Discussion started by: Renjesh
6 Replies

10. Shell Programming and Scripting

Modify Perl script to work with txt - Permissions script

Hi I have this code, and i want work with a ls -shalR output in .txt What i need read to do this?? Where start? #!/usr/bin/perl # Allrights- A perl tool for making backups of file permissions # Copyright (C) 2005 Norbert Klein <norbert@acodedb.com> # This program is free... (1 Reply)
Discussion started by: joangopan
1 Replies
Login or Register to Ask a Question