I often use "ls -lut" in troubleshooting. What that does is show you the last time a file was "used", which can be very helpful in tracing whether or not something happened when you expected it to. However, when it comes to shell scripts, there are some quirks you need to know about.
For example, suppose you have a a cron job set to fire off at 3:00 AM. That job in turn may fire off other scripts or programs but your main concern is "did it run?", so when you log in the next morning you issue an "ls -lut" on it. You expect to see 3:00 for the time stamp, but you may not.
To illustrate this, let's take a simple script "t". Here it is:
sleep 120
We'll also create a testing harness, "tt":
date rm t echo "sleep 120" > t ls -lut t echo "Running bash" /bin/bash ./t ls -lut t echo "Running sh" /bin/sh ./t ls -lut t echo "Running ksh" /bin/ksh ./t ls -lut t echo "Running csh" /bin/csh ./t ls -lut t
The output from that script shows that for these shells, the "used" time for "t" gets set to the time it stops, not when it starts. That may actually be useful - especially if you didn't expect the script to run as long as it did. On the other hand, if this wasn't run by a cron job and you need to know when it was run, you don't have that: you only know the end time.
Note that a Perl script will show only the start time, as will a binary executable:
$ cat t.pl
#!/usr/bin/perl
sleep 120;
exit 0;
$ touch t.pl;ls -lut t.pl;./t.pl;ls -lut t.pl
-rwxr-xr-x 1 apl apl 35 Apr 10 12:09 t.pl
-rwxr-xr-x 1 apl apl 35 Apr 10 12:09 t.pl
$ cat tc.c
#include <stdio.h>
main ()
{
printf("Hello World\n");
sleep(120);
}
$ make tc
cc tc.c -o tc
$ ls -lut tc;./tc; ls -lut tc
-rwxr-xr-x 1 apl apl 12608 Apr 10 12:09 tc
Hello World
-rwxr-xr-x 1 apl apl 12608 Apr 10 12:09 tc

Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar