Tracking change inside the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tracking change inside the script
# 1  
Old 10-15-2012
Error Tracking change inside the script

we have more then 10 jobs scheduled in cronjob.. but we can see some of the script has been changed without any notification.. can we write any script which captures any changes inside the scripts with time of change and user name like .. or any other option apart from this ??
Plz help ..

Last edited by jim mcnamara; 10-15-2012 at 08:40 AM..
# 2  
Old 10-15-2012
I'm confused.

1. Who owns/runs the crontab? oracle? root?
2. How many users on the system know the password to the account that owns the crontab file?

Since crontab executes user-written scripts and those can change at any time so:
3. Who owns the scripts that are changing?
4. Are the crontab entries themselves changing?

cron does not change scripts, people do. cron does not change it's own entries, people do. If you can tell us more maybe we can help you find the problem.
# 3  
Old 10-15-2012
hi jm.

correct it is changed by pepole only... they are different user which have acces to cron job.. they may change .. with the requirement .i want to track .. if any change happens in between inside the script . i can track all these changes .plz provide possible way . to notice change, changed by user and change time.
# 4  
Old 10-15-2012
One way of many to do this:

Part A.
create a list of script files with full script files names: e.g., /path/to/script.sh
Next use that list to create a file with checksums
Code:
while read fname 
do
  /usr/bin/cksum $fname
done < /path/to/list.txt > /path/to/checksums.txt

Now you are set up. NOTE: if your detect a change, that means you have to redo the checksums, if the change was okay and you want to keep it as part of the cron jobs.

Part B
create a script to check the files
Code:
#!/bin/ksh
# check.sh
while read fname 
do
  /usr/bin/cksum $fname
done < /path/to/list.txt > /tmp/test.txt
/usr/bin/diff  /tmp/test/test.txt  /path/to/checksums.txt > /dev/null
# diff returns 1 if the files are different - meaning code has changed
if [ $? -eq 1 ] ; then 
   echo 'warning files have changed check /tmp/test.txt' | /usr/bin/mailx -s 'Warning' \
     netdbaind@somecompany.com   
fi
exit 0

Put this entry into cron. Be sure your buddies cannot change/edit your check.sh
Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * *  /path/to/check.sh

You may be tempted to make it every minute. Don't. One day you will come into work with 190 emails waiting for you.
This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 10-16-2012
Thanks Jim,

if i am not wrong the diff here will come in cksum format rit.. can we change this cksum format in text so that we can easily know what has changed..?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make change to variable value inside of awk script

Hello, I have text data that looks like this, Mrv16a3102061815532D 6 6 0 0 0 0 999 V2000 -0.4018 1.9634 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 1.5509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 0.7259 ... (9 Replies)
Discussion started by: LMHmedchem
9 Replies

2. Shell Programming and Scripting

Is it possible to change paths inside a bash script?

i have some script with some paths inside it. The idea is to some files which is on desktop copy and move to another location. Problem is that inside script is similar to this: cp test1.zip /root/help/ because I allways have another zip files, does it possible to have some input which ask me... (18 Replies)
Discussion started by: tomislav91
18 Replies

3. Shell Programming and Scripting

How to change the color inside email using shell script?

hi, i want to send an email from unix using mailx command. mailx -s "subject" "email@abc.com" < email.txt Email.txt contains some file names that are transferred successfully and some that failed. so the files that got failed to tranfer, should be displayed in red color in the mail. is it... (1 Reply)
Discussion started by: Little
1 Replies

4. Programming

Is it possible to change search inside .pdf or .doc files?

the titele was wrong ... the true one is: Is it possible to search words inside .pdf or .doc files? is it possible if i changed the word into binary combination:eek:? and this way is super too hyper huge of greatest codes i ever seen:D to read only 1 word so is there any other ways:confused:? ... (1 Reply)
Discussion started by: fwrlfo
1 Replies

5. Programming

Need a tracking PHP Script – “how long people stay on the website?”

I want to know, is there a way to track how long anyone has been logged into website and then insert it up for each time they have logged on. In case, user a logs in for 30 minutes, then later comes back and logs in for an hour, then later comes back and logs in for 50 minutes, Add... (1 Reply)
Discussion started by: AimyThomas
1 Replies

6. UNIX for Dummies Questions & Answers

Change to different user id inside a program

Hi, There is a process ( built in C/C++) which starts with my user id and I need to execute a specific function with a different user id. Is there any api so that I provide userid, passwd and the next instance the process will have the new user id privileges. - Pranav (3 Replies)
Discussion started by: k_pranava
3 Replies

7. Red Hat

Can not change timestamp on directory inside cifs mount

Greetings, I have an rsync server that is unable to change the timestamp on any directories inside of cifs mounts. The same thing happens on all of my red hat machines. These machines are all patched, touch -t works on directories inside any other filesystem including NFS mounts. This is... (0 Replies)
Discussion started by: Create
0 Replies

8. Shell Programming and Scripting

Another question for tracking failed logins via script

Hello Experts, I have this initial shell script that tracks failed login attempts: #!/bin/bash #Fetch failed user logins to file failed-logins.txt grep -i failed /var/log/secure | awk '{ print $1, $2" ", $3" ", $9" ", $11 }' > failed-logins.txt #Splitting the failed-logins in... (10 Replies)
Discussion started by: linuxgeek
10 Replies

9. Shell Programming and Scripting

Shell script in tracking both the passed and failed login in a unix server

Can you help me in providing the following output or a quite similar to this from a shell script ? *** Logins Summary Information ***** ---------------------------------- Failed Login Attempts for Invalid Accounts Date Time IP-ADD Account ... (0 Replies)
Discussion started by: linuxgeek
0 Replies

10. Shell Programming and Scripting

Script for tracking from directory to file

Hi , I am pretty new to scripting, and I trying to write a script which is not working as I expect to .... I am trying to write a script which starts from top directory and tracks all the folders and sub-folders till it reaches a file and gives the list of files as output for a given... (2 Replies)
Discussion started by: Rahul00000
2 Replies
Login or Register to Ask a Question