Check if a program/script was run at startup?
Solution 1
You can look at the access time for the script. This isn't 100% reliable (since some filesystems can have noatime
set). But it's usually useful for init-scripts, e.g.,
find /etc -type f -atime -1
I've found it useful for quite a while.
Solution 2
pstree
will give you a detailed output of process running in a tree format.
Sample output here
init─┬─auditd───{auditd}
├─crond
├─docker─┬─10*[bash]
│ ├─docker───5*[{docker}]
│ ├─docker───4*[{docker}]
│ ├─2*[docker───3*[{docker}]]
│ ├─start-app.sh─┬─java───40*[{java}]
│ │ └─tail
│ ├─start-app.sh─┬─java───81*[{java}]
│ │ └─tail
Related videos on Youtube
Comments
-
tuantm over 1 year
In Linux, there are many files we can modify to add a program run at start up (/etc/rc.local, bashrc, bash_profile, $HOME/.config/autostart, ...) ? Now I have a reverse question: I have a program, can I check if this program was run during start up?
**Note: The program can run once at start up and exit
-
jasonwryan over 7 yearsWith systemd, if it was started as a service you can read the journal.
-
tuantm over 7 yearsThanks @jasonwryan. That's not cover my case. The program can run just by you execute it,
-
jasonwryan over 7 yearsThen, unless it includes a logging facility, how would you expect to be able to determine if it ran or not?
-
MatthewRock over 7 yearsI suggest expanding your question. This looks like X-Y question. Why would you want to check that? Is this check looking for some speciifc program?
-
-
jasonwryan over 7 yearsThis assumes the process is still running...
-
tuantm over 7 yearsThanks @Murillo. But that is not my case, because a program can run and exit immediately so if you can't check it in process management information information
-
tuantm over 7 yearsThanks @Kailas. Same as jasonwwryan said, this must assume that the process is still running.
-
Ned64 over 7 yearsThe same informatoin can be output with stock
ps
:ps auf
, or on modern systems withsystemctl status
- if the process is still running.