Crontab update


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Crontab update
# 1  
Old 04-25-2018
Crontab update

Hello.

We have a big crontab file where we need to comment out for few countries and also uncomment out based on situations . Could someone let us know how this can be done using a script .

Sample file look like & here i need to comment/uncomment based on country code .

Code:
0-59 ... u/app/atms/us/bin/location  MX K1
0-59 ... u/app/atms/us/bin/location  GB K1
0-59 ... u/app/atms/us/bin/location   US K1

Thanks
Ron T

Last edited by jim mcnamara; 04-25-2018 at 12:38 AM..
# 2  
Old 04-25-2018
You can use sed or awk to change the file. However that is not 100% safe. Some few older UNIXes do not "see" changes to crontab files unless the crontab -e [username] command is used. Not vi. Not sed. Not awk.

What OS and version do you have? -- the output of
Code:
 uname -a

is perfect.
# 3  
Old 04-25-2018
Once we know what operating system you're using (as requested by jim McNamara), we'll also need to know what shell you're using.

And, we need to know how you plan to tell your script which country code or country codes are to be processed and whether the invocation of your script is supposed to comment out that country code or make the entry for that country code active.

What are the "situations" you mentioned? How can your script determine whether or not each such "situation" exists?

Will the crontab file to be updated be the crontab file of the user running this script? If not, how will the user running your script get permission to modify the crontab file of the user whose contab file it is that you want to update?

If you can show us what you have already tried to solve this problem on your own, it would help us understand what you are trying to do and where you are stuck.
This User Gave Thanks to Don Cragun For This Post:
# 4  
Old 04-25-2018
Thanks . We are having AIX ,Linux Boxes & Shell is bash..

We would want to comment specific lines in the crontab file based on the country code & we would need to uncomment the lines based on the country code . for e.g MX is mexico, GB is england ..

We nowus crontab -e and does the editting manually to make the changes . For e.g if we waant to comment out let says 100 process running in different countries then it is time consuming, any help in this would be greatly appreciated .

Ron T
# 5  
Old 04-25-2018
Hello ron5174,

It's a slight bug bear of mine, but GB is for Great Britain. England is a part of that nation state.


Kind regards,
Robin - actually living in England, but proud to be British
# 6  
Old 04-25-2018
You can edit the crontab file directly using any tool/script provided you know that, of its own accord, it will not see the changes immediately. As long as you have your wits about you, and understand what's going on, you can manipulate crontabs.

See my post#4 on this thread:
Rename inside the crontab file
# 7  
Old 04-25-2018
my bad , GB is for Great Britain Smilie So what i am getting is that we need to manually update the crontab file and there is no other way we can do this . is my understanding correct ?
This User Gave Thanks to ron5174 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

How to update Solaris 10 Update 3 to Update 11?

Hi friends, We have a Solaris machine running 10 update 3 -bash-3.2# cat /etc/release Solaris 10 11/06 s10s_u3wos_10 SPARC Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms. ... (6 Replies)
Discussion started by: prvnrk
6 Replies

2. Red Hat

RedHat 5 update 9 BASH update issue

Hi i want to update the BASH because of the "shell shock" vulnerability. my RedHat 5 is clean install with the default mirror site. when im running the command: yum update bash im getting a message saying there is no update. you can see in the attach picture... what am i doing wrong? is... (4 Replies)
Discussion started by: guy3145
4 Replies

3. Programming

MYSQL - trigger update on record insert or update

Right I have a MYSQL database with table1 with 3 columns, colA, colB and colC. I want to combine the data in the 3 columns into a 4th column names col_comb. Here's the SQL command that works: UPDATE table1 SET `col_comb` = CONCAT( `colA` , ' - ', `colB` , ', ', `colC` ); So now I want this... (5 Replies)
Discussion started by: barrydocks
5 Replies

4. Solaris

Is it possible to "upgrade" Sol10 update 9 to update 10?

Is it possible to "upgrade" Sol10 update 9 to update 10 by booting from the DVD? I had never even tried this until a user asked me to do it, so i tried and it just hung there after the part where it reads the rules.ok file. Is this even possible to upgrade? or does it have to be a new install. ... (5 Replies)
Discussion started by: BG_JrAdmin
5 Replies

5. Solaris

Install update 6 on solaris with update 3

I want to update my solaris 10 server which is currently on update 3 stage. A new application require it to be on update 6. What is the best way to make it update 6. should i just install the patch or should i go for the liveupgrade?? thanks for you help in advance (3 Replies)
Discussion started by: uxravi
3 Replies

6. UNIX for Dummies Questions & Answers

How to get the last crontab

Hi all, can anybody tell how to get the last crontab if it is deleted. is there any way to get the crontab back? or it will it be staored anywhere ? its very urgent, can anybody help for the same? Thanks, Vinay (5 Replies)
Discussion started by: vinayakatj56
5 Replies

7. UNIX for Advanced & Expert Users

Pro*C Update not working from Crontab

Dear All, I have writen a Pro*c program that does a data base select,insert,update statements and I have scheduled the program to run from crontab, It is runing fine for the select insert and commit statement till it reaches the update statement , it throws the following error: SQL On IPB... (2 Replies)
Discussion started by: alhallay
2 Replies

8. UNIX for Dummies Questions & Answers

UNIX "Crontab update"

Is there another location to update a cron that's run daily. I have updated the root cron located "/var/spool/cron/crontabs " After the update the cron doesn't run at the new time it was set at. It continues to run at the old time. Checking the root cron after it has been updated show the... (3 Replies)
Discussion started by: ddrivera
3 Replies

9. Solaris

Unable to update the Crontab

Hi Everyone, Each time I do update the crontab, it gets reset after exiting from the telnet session. I'm using Solaris 2.8 So it goes like this: Step 1: Login as root, from a telnet session Step 2: Crontab -e (I make modification) Step 3: Save and exit Step 4: Type crontab -l , changes... (4 Replies)
Discussion started by: Jeremy3
4 Replies
Login or Register to Ask a Question