LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-13-2012, 12:25 PM   #1
neoanomally
LQ Newbie
 
Registered: Nov 2010
Posts: 13

Rep: Reputation: 0
Keep track of when a script runs


There is a perl script that runs on this webserver whenever a user does something. Is there a way I log when that script runs or do something to track time and the amount of times the script runs?

Thanks,
 
Old 12-13-2012, 12:57 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You can check appropriate system logs. Since every OS maintains logs at different locations, so it depends upon which OS this webserver has? Also you can check /home/username/.bash_history file to check history of commands run by that user.
 
Old 12-13-2012, 01:17 PM   #3
neoanomally
LQ Newbie
 
Registered: Nov 2010
Posts: 13

Original Poster
Rep: Reputation: 0
I should have specified the restrictions I have. The permissions on the server are that one group has access to apache, and a separate group is the only group that has root access. I only have access to my directory and the directory for my website, this is stored on the web server. I could request access to logs, but that could take weeks with Christmas right around the corner. Is there a way to manually log things, like over a 2 day period? Thanks, again.
 
Old 12-13-2012, 01:49 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Which distro i.e. operating system is there in webserver? To check, login on webserver and invoke:
Code:
uname -a
As far as I remember, a normal user can read common system logs. But as I said which distribution is there.. perhaps then people can better help you.
Also do you want to check script run logs for yourself or any other user?

FYI, system logs contains many type of log files (in Linux, common logs are maintained in /var/log/.... directory. In Solaris it's in /var/adm/... directory). Also a webserver may maintain it's logs somewhere else (I am not sure).
In the meantime, you can try:
Code:
grep <username> /var/log/*
OR
grep <username> /var/adm/*
One more thing, /home/username/.bashrc_history, contains a list of all commands user has invoked, so you can check that also.
 
Old 12-13-2012, 02:03 PM   #5
neoanomally
LQ Newbie
 
Registered: Nov 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you very much for the commands. I am able to look up the commands that I have run, but I get a "Permission denied" accessing the specific logs in the log folder. I guess I could just add to that perl script so that the end it concatenates the system time to a file. The company keeps a tight lock on permissions within the server.

Server is Red Hat 4.. 2.6.9-89.ELsmp
 
Old 12-13-2012, 03:14 PM   #6
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
If you do not have permissions, then it cannot help. But still you can do:-

First check /home/username/.bash_history, using (Note: it will not show time of script run, but at least will tell you how many times script has run):-
Code:
grep "<scriptname.pl>"  /home/username/.bash_history
Then check system logs again as:-
Code:
awk '/<scriptname.pl>/ && /<username>/ {print $0}' /var/log/messages*
It will list all logs entries (if available in it) when user <username> run the script. Similarly you can invoke same command for other log files as well. Take a note, in these commands, just replace the filename (marked in green) to check other log files.

Last edited by shivaa; 12-13-2012 at 03:32 PM. Reason: Text formatting
 
1 members found this post helpful.
Old 12-13-2012, 05:15 PM   #7
neoanomally
LQ Newbie
 
Registered: Nov 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you very much. That was what I was looking for. After much time I finally found it. Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compute cluster runs old script after changing the script Reignfire Linux - Server 1 09-27-2012 06:35 AM
Script runs Manually but not in Cron, yet other parts of the script run mccartjd Linux - Newbie 5 01-08-2012 07:54 PM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 07:19 PM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 11:48 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM


All times are GMT -5. The time now is 12:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration