Skip to main content

Posts

Showing posts with the label Check long running LINUX process

Check long running UNIX process

To check how many seconds have elapsed since a process started you can use this small shell script: #!/bin/bash init=`stat -t /proc/$1 | awk '{print $14}'` curr=`date +%s` seconds=`echo $curr - $init| bc` name=`cat /proc/$1/cmdline` echo $name $seconds save it on a file called sincetime and give permissions for your user to run it and put it in your $path. Than, the command: sincetime <pid> will return the name of the process with the given pid and its age in seconds. Find Out How Long A Process Has Been Running In Linux ps command has different format specifiers (keywords) that may be used to control the output format. We are going to use the following two keywords to find the uptime of an active process. etime – elapsed time since the process was started, in the form [[DD-]hh:]mm:ss. etimes – elapsed time since the process was started, in seconds. First, you need to find out the PID of a process. The following comm...