changing cron using bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting changing cron using bash script
# 1  
Old 04-26-2010
changing cron using bash script

How can I change the cron entries only for ABC and XYZ from dosomething_1.0.sh to nowchanged_2.0 using a bash script ?

Any help will be appreciated.


Code:
 
# 
# ABC
00,05,10,15,20,25,30,35,40,45,50,55  * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1
#
#
##
# DEF
00,05,10,15,20,25,30,35,40,45,50,55  * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1
#
# 
# XYZ
00,05,10,15,20,25,30,35,40,45,50,55  * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1
#
# 
# LMN
00,05,10,15,20,25,30,35,40,45,50,55  * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1
#

# 2  
Old 04-26-2010
Hi.

Use at your own risk! Take a backup of your crontab file first.

Code:
crontab -l | sed '/# ABC/{N; s/dosomething_1.0.sh/nowchanged_2.0/;}' | crontab -

(repeat similar for XYZ)
# 3  
Old 04-26-2010
Thank-you for the quick replay. Work great !

How can I use a wildcard eg. dosome[*] in the above case ?
# 4  
Old 04-26-2010
For example:
Code:
crontab -l | sed '/# ABC/{N; s@dosome.*@nowchanged_2.0 1>/dev/null 2>\&1@;}' | crontab -

# 5  
Old 04-26-2010
Thanks ! it works like charm.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing date using bash script

I am trying to change dates in a bash script. I have a start time and an endtime and want to increment the times. Basically the month and day have to be incremented in a loop to create two strings, stm and etm defining the start and end times. stm="2014-05-13T00:00:00"... (4 Replies)
Discussion started by: novilatte
4 Replies

2. UNIX for Beginners Questions & Answers

Connecting and changing variables in Bash script

#!/bin/bash X=$(</home/cogiz/computerhand.txt) # (3S 8C 2H 6D QC 8S 4H 5H) Y=$(</home/cogiz/topcardinplay.txt) # KS A=( "${Y::1}" ) B=( "${Y:1}" ) for e in ${X}; do if ]; then # searching for valid cards K,S or 8 ... (0 Replies)
Discussion started by: cogiz
0 Replies

3. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies

4. Shell Programming and Scripting

Changing script from csh to bash

Hello Guys I have a script working fine on csh, but I would like to change it to bash, how I should change this command to be able to work as bash script. :wall: if ( $fsw > "0" ) then foreach swath ( `awk 'BEGIN {for (i='$fsw';i<='$lsw';i++) printf ("%s\n", i) }'` ) ## work to be done... (2 Replies)
Discussion started by: jiam912
2 Replies

5. Shell Programming and Scripting

Bash Shell Script and Cron

How can I tell a script to only execute if the other scripts exits successfully? So "script A" executes and if it executes successfully (0),then "script B" will run or else "script A "executes and it exits unsucessfully (1) then "script B" will read return code (1) and will not execute ... (3 Replies)
Discussion started by: metallica1973
3 Replies

6. Shell Programming and Scripting

how do I run bash script using cron job

How do I run bash script using a cron job? I have tried to just write the path of the script, but that didn't work. (1 Reply)
Discussion started by: locoroco
1 Replies

7. Shell Programming and Scripting

Changing File Time Stamp (Bash Script)

I need some help recovering from a "slight" screwup. We just moved 3 TB of data from one RAID Array to another. Low lever archive files. This was done with a regular cp (for some reason) and now we have lost all the timestamps on the files, and we urgently need to get the timestamps back on these... (7 Replies)
Discussion started by: chj
7 Replies

8. UNIX for Dummies Questions & Answers

Cron changing folder for scripts

I would like to ask if cron when running a planned script changes the current folder for the script. Thank you! (2 Replies)
Discussion started by: MartyIX
2 Replies

9. Shell Programming and Scripting

Bash script: issue changing directories in script

I am working on a script that checks two arguments at the command line. The first argument is a search pattern, the second can be a file or a directory, if it is a file a second script is called that checks it for the search pattern. If the second argument is a directory, it checks for the search... (5 Replies)
Discussion started by: Breakology
5 Replies

10. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies
Login or Register to Ask a Question