![]() So if the program run_constantly.py crashes, the following program still thinks that the run_constantly.py is running (since both process IDs are same), and therefore continues to go into the else loop to sleep and monitor again. However, the major problem that I am currently facing is that the process ID of this program and the run_constantly.py program turns to be same once I schedule the run_constantly.py using the scheduler.add_cron_job() function. In the above program, I check if res = 0, and if so, then I use Python's scheduler to schedule the program. if the program is still running) and if it does not exist, it returns 0. Bpytop is available for various linux distributions and macOS. bashtop users can expect similar features in bpytop since bpytop is ported from bashtop and completely written in Python. ![]() ![]() checkPID() basically checks if the process ID still exists (i.e. BpyTOP is another Linux command-line utility for resource monitoring among many other utilities like a top, Htop, Bashtop, etc. I have not included the checkPID() function here. #the process is running sleep and then monitor again Scheduler.add_cron_job(foo.Run_Module, year=date_time.year, day=date_time.day, month=date_time.month, hour=date_time.hour, minute=date_time.minute+2) # if res is 0 then program is not running so schedule it # call the function checkPID to see if the program is running or not Now I run another program which has the following code to monitor the program run_constantly.py from a Linux environment: def Monitor_Periodic_Process():įoo = imp.load_source("Run_Module","run_constantly.py") I initially run this program manually, which writes its process ID to the file "PID" (in the location out/PROCESSID/PID). The main part is that if the command fails, it defaults to the root user. I am using another Python program to do so.įor example, say I have to constantly run a process called run_constantly.py. Bug fix - Linux process monitoring failing because of Python bug. If the program stops, then I have to start the program again. I am trying to constantly monitor a process which is basically a Python program.
0 Comments
Leave a Reply. |