Timestamp of previous command issued

James Wilkinson ubuntu at westexe.demon.co.uk
Sat Apr 16 12:11:22 UTC 2005


benjamin wrote:
> Is there a way to check the timestamp of a previously run command ?

Maybe. Depends on the command. (And I assume you mean "shell command"
here).

If you've got your filesystems mounted without noatime (the default),
and if the command wasn't a shell built-in or alias, you can tell the
last time a file (such as a command) was accessed by the system or
anyone on the system:
ls -lu $FILE
where $FILE is the command in question.

The command
type $COMMAND
tells you what sort of command $COMMAND is. For example,
james at kendrick:/bin$ type ping
ping is /bin/ping
james at kendrick:/bin$ type ls
ls is hashed (/bin/ls)
james at kendrick:/bin$ type echo
echo is a shell builtin

So to check the last time someone accessed the rmdir command, you might
run:
james at kendrick:/bin$ type rmdir
rmdir is /bin/rmdir
james at kendrick:/bin$ ls -lu /bin/rmdir
-rwxr-xr-x  1 root root 20456 2005-04-15 17:04 /bin/rmdir
and find that it was 4 past 5 yesterday afternoon.

If the command actually did something to the filesystem, then you might
be able to pick up the file modification time with
ls -l $FILE
(which is when the file itself was last modified). Or you might be able
to use a file status modification time with
ls -cl
which shows the last time that (for example) the file owner was changed
or the permissions altered (or the file created).

In general, those are the three timestamps a Unix-like system keeps.
The only other option would be to hope it did something that made the
system logs.

Hope this helps,

James.

-- 
E-mail address: james | "Drums must never stop. Very bad if drums stop."
@westexe.demon.co.uk  | "Why? What will happen if the drums ever stop?"
                      | "Bass solo."




More information about the ubuntu-users mailing list