crontab entry modification using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting crontab entry modification using shell script
# 1  
Old 06-29-2007
crontab entry modification using shell script

hi Friends,

iam trying to write a script which will grep the particular entry in crontab of root and enable/disable it .iam a novice in scripting. your suggestions are most welcome..please help

Cheers!!
# 2  
Old 06-29-2007
It will be easier in Perl or sed

You can doing using perl or sed.

To edit cron jobs of any user you will need to edit the file with corresponding username under /var/spool/cron (assuming Red Hat linux.. you can find this path for different *nix systems).

Hope that helps you.
# 3  
Old 06-30-2007
My suggestion is do not do that! First of all, simply changing the crontab file is NOT correct. You must use the crontab command or cron will not notice the change.

But what you should do is make the entry in root's crontab a shell script. And the shell script should, at the top, do something like:
Code:
if [ -f /var/root-crontab-control/inhibit-file1 ] ; then
        exit 0
fi

This is much cleaner than having scripts that fiddle with root crontab. Sooner or later the scripts fail and root is left with no crontab. With the inhibit-file concept, you just touch a file to inhibit the corresponding cronjob and then later you remove the inhibit file when you the script to run all the way.
# 4  
Old 06-30-2007
thats seems to be sth smart work Perderabo,but that would be much better if you can explain the inhibit-file concept with an example.

Thanks in Advance..
# 5  
Old 07-01-2007
Per, I have a doubt here.

Modifying the cron entries via scripts and not through crontab command and touching the cron file.

Won't that enable crond to understand that cron file for a user has been changed ?

Won't that work ... ? Assuming that the user script is not going to mess up with the cron file won't the above logic work ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell backup script modification

so I'm using this shell script someone made to backup data on a server in an archive (gpg encrypted) and upload to an FTP (meant to be run as a cron job daily). can one of the experts here confirm if the script is fine? It is meant to backup the folder /opt and the sql data i want to know how I... (9 Replies)
Discussion started by: galapagos8000
9 Replies

2. Shell Programming and Scripting

Needed shell script to read txt file and do some modification

Hi ...programmers... I need a shell script to perform some specific task.. my txt file looks like this netcdf new { dimensions: XAX1_11 = 11 ; variables: double XAX1_11(XAX1_11) ; XAX1_11:point_spacing = "even" ; XAX1_11:axis = "X" ; float DEPTH(XAX1_11) ;... (19 Replies)
Discussion started by: Akshay Hegde
19 Replies

3. Shell Programming and Scripting

Notification of the modification of a specific entry in a file

I need to get notification via email when the line containing a pattern is changed in a file. Not during the time any changes to file occurs. Ie if we reset a user password say example, demouser the hash in the line containing the word demouser in the file /etc/group changes. So when this change... (1 Reply)
Discussion started by: anil510
1 Replies

4. Shell Programming and Scripting

Modification in shell script

Hello Team, I have prepared script which will check for listening message for ports 1199,1200 and 1201. I need modifcation in script in such a way that if port 1200 is not listening then it should message rmi port 1200 is not listening. Smap for port 1199 and 1201. kindly guide me to acheive... (4 Replies)
Discussion started by: coolguyamy
4 Replies

5. Solaris

crontab entry to run a script on 1st of every month.

What should be the crontab entry in solaris to run a script on 1st of every month? Is this correct? 00 02 1 * * <script to be executed> (5 Replies)
Discussion started by: deepaksahni0109
5 Replies

6. Shell Programming and Scripting

Help with Shell Script Modification

Hi all Iam very new to Shell Scripting, I have to modify a shell script looking at an existing one except that it will query against some table X in A database. Befor Spooling check if there are any reload files if there archive the files. The above scipt executes some abc.sql which will b a new... (2 Replies)
Discussion started by: Varunkv
2 Replies

7. AIX

crontab entry

Hi. I'm new to AIX and I need to create a crontab entry to run a script every first 5 business days of the month? please help. (2 Replies)
Discussion started by: udelalv
2 Replies

8. UNIX for Dummies Questions & Answers

File comparision and modification using shell script

Hello everyone, I would like to know how to compare two files and modify any differences with some other data using shell script. I think it would be better understood with an example. I got two files named 'filex' and filey'. 'filex' is constant file without any changes in data. 'filey' is... (2 Replies)
Discussion started by: maddy81
2 Replies

9. Solaris

Modification history for Crontab

Hi all - I've searched the forums and seen a few questions related, but nothing which explicitly answers what I'm looking for. I need to know if there's ANY way to get the modification history of any users crontab. Yes, I know that crontabs are in /var/spool/cron. I know that the... (2 Replies)
Discussion started by: amcq
2 Replies

10. UNIX for Dummies Questions & Answers

Shell script: last modification date for a file

Hi i have a ques in Shell scripting: ques: accept a filename as a command line argument. Validate the input and display the last modification date for that file. Help pls. (4 Replies)
Discussion started by: onlyc
4 Replies
Login or Register to Ask a Question