Execute a shell script after a particular command is run

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute a shell script after a particular command is run
# 1  
Old 07-13-2009
Execute a shell script after a particular command is run


I need to run a script whenever the Cron file is modified.
The requirement is whenever a user modifies the cron file, the script should run automatically.
Can you please provide your inputs ?
# 2  
Old 07-13-2009
If you stored the sum value of the output from crontab -l somewhere then you could run a conjob to compare the actual sum value from crontab -l with the stored one and run something if they were different.

Manual setup:
# crontab -l | sum > /root/crontab-l.sum

Script to run from root cron:
LIVECRONSUM=`crontab -l | sum`
STOREDCRONSUM=`cat /root/crontab-l.sum`
if [ ${LIVECRONSUM} -ne ${STOREDCRONSUM} ]; then
  #run something
  logger -p daemon.notice "The root user crontab has changed!"
  # updated stored value so that the above only runs once
  crontab -l | sum > /root/crontab-l.sum

# 3  
Old 07-21-2009
Thanks a lot.
What i want is that whenever user modifies the cron file, the script should run automatically and no manual intervention is needed to run the script.
The script will then find the differences between the old and new cron file.
# 4  
Old 07-21-2009
isn't the above logic what you're looking for?
# 5  
Old 07-27-2009
Will the above process automaticall invoke the process if someone modifies the cron ?
I want the script to be executed automatically and not to be run by the user.
# 6  
Old 08-03-2009
The intention is to run it from cron, so that means it will run as frequently as you want it to but will only alert you if and when a change is seen.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns. When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns. sed -i 's/$/\r/' lf_file.txt But that same... (1 Reply)
Discussion started by: hawkman2k
1 Replies

2. Shell Programming and Scripting

How to execute application command in shell script?

friends, i have application commands to execute in shell script it is something like this. i will login with user data it takes me to $ prompt. Example given below login: data ps : xxxx $ MNSinput --this takes me to greater than prompt > > ops --this is command i enter this output... (7 Replies)
Discussion started by: udaykrishna
7 Replies

3. Shell Programming and Scripting

Need to execute Oracle relocation command in shell script

Hello, I need to execute below command in shell script srvctl relocate service -d $database -s $service -i $avail -t $pref -f and also need to get the errors ,if any,in another file. What's the right way to execute such commands in shell script? Best regards, Vishal (1 Reply)
Discussion started by: Vishal_dba
1 Replies

4. Shell Programming and Scripting

Help me!how to run autosys command in UNIX shell script

Hi all, Here is my scenario.. i need to get dates from an existing autosys calendar and compare it with current date with in a unix shell script. Please help me out and give me an approach to handle this....... the general autosys calendar command used is autocal_asc ,but this is... (1 Reply)
Discussion started by: shrik12345
1 Replies

5. Shell Programming and Scripting

run command in a script shell

Hello, Please i'd like to run command in a script shell , how can i do ? here my commands : cd blcr-build // run command in this rep sudo insmod ./blcr_imports/kbuild/blcr_imports.ko //root sudo insmod ./cr_module/kbuild/blcr.ko //root Thank you. (1 Reply)
Discussion started by: chercheur857
1 Replies

6. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

7. UNIX for Dummies Questions & Answers

How to execute command after telneting in shell script?

Hi , I have to write a shell script to telnet to specific host and execute the admin command there. Please help me to do that. Eg : telnet hostname portno admin command exit (3 Replies)
Discussion started by: arukuku
3 Replies

8. UNIX for Dummies Questions & Answers

ssh command to execute shell script in another server

ssh -q <hostname> /opt/tcs/satish/tst.ksh ssh -q <anotherserver> /opt/tcs/satish/tst.ksh tst.ksh has "nohup <command> & " when i execute below script , its throwing error as nohup can not be found ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log & can someone let me... (5 Replies)
Discussion started by: only4satish
5 Replies

9. Shell Programming and Scripting

write a shell script to execute a command

Hello all, I have just started doing shell scripting. I want to read a file which stores the status of my job I have submitted on a cluster. The file looks something like this : ========================FILE============================= crab: Checking the status of all jobs: please wait... (4 Replies)
Discussion started by: learn_linux
4 Replies

10. Shell Programming and Scripting

shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out? #!/usr/bin/ksh test="cal > /tmp/tmp.txt 2>&1" $test I know it will work for the following format: #!/usr/bin/ksh cal > /tmp/tmp.txt 2>&1 However, I need to get the command from the user in... (1 Reply)
Discussion started by: redtiger
1 Replies
Login or Register to Ask a Question

Featured Tech Videos