PDA

View Full Version : How to know if my script is sleeping



akshay-sulakhe
October 26th, 2013, 11:22 PM
Hey guys, I want to run a script, but i should know if the script is sleeping. Like for eg: it should print 1 when it is sleeping. rest of the time i want it to calculate value of pi... Just for fun this is, nothing else. Any ideas?

ofnuts
October 27th, 2013, 12:56 PM
Have it write a file into /var/tmp just before going to sleep, and erase the file on wake up?

Otherwise, if you have the PID, "cat /proc/$pid/stat" or "cat /proc/$pid/status" ("stat" is for programs, "status" is for humans) and check the "state": see http://linux.die.net/man/5/proc