4

I need to find out the history of a script execution in my Linux box. I need to know, how many times it was restarted, by who and when. This is not a system process. This is a ksh script.

Is there any way to do this? Thanks for any help.

----- Update

Ok, I get it that I cant retrospectively get all the data that I had initially asked for. However, could I even get how many times this ksh was run and when? I know the user that runs it.

Thanks for any help.

partha
  • 141
  • 4

2 Answers2

7

Without real auditing activated, in the general case the answer will be that this is not possible.

If the users you are concerned about cannot change the script, you easily can add a very simple logging function with the help of the logger command.

Add a line like the following to your script:

logger Myscript was run by user $USER
Sven
  • 98,649
  • 14
  • 180
  • 226
5

You can't do this retrospectively unless you had auditing enabled. Going forward you could enable auditing or you could modify the script to log it's activity.


Update for your update:

If you know the user you may get something out if their ~/.bash_history but it's not really a good place to look as it is easily edited and bypassed see here. Auditing on the other hand is much more difficullt to tamper with.

user9517
  • 115,471
  • 20
  • 215
  • 297