I am writing a background process in DB/C which is new to me. I can't find anything in the language that will give me it's PID like in C. I need to start and stop this process with cron. I am having trouble finding a way to do this.
I thought maybe I could set up another cron file and run it out of there rather than root and I might get a user ID and then do a "ps -u "myuser" -o PID >> PID" and I'd get the PIDs and kill them. No luck. The user is still "?" as in any cron job.
I thought I had a work around by deleteing the processes work files in cron and that would cause an error which would terminate the program. But I realized it would kill the program at some random time in the morning when the first activity caused the error and I would have no way to know when to restart it.
Can someone suggest a way to do this? Is there a way to use "ps" to get the PID I am missing? Is there a way to store the data from "ps -ef | grep "myprogram" so that I can draw the PIDs out of it? (My program runs as parent and child.) Is there a way to force a user name onto the cron job for easy identification?
I thought maybe I could set up another cron file and run it out of there rather than root and I might get a user ID and then do a "ps -u "myuser" -o PID >> PID" and I'd get the PIDs and kill them. No luck. The user is still "?" as in any cron job.
I thought I had a work around by deleteing the processes work files in cron and that would cause an error which would terminate the program. But I realized it would kill the program at some random time in the morning when the first activity caused the error and I would have no way to know when to restart it.
Can someone suggest a way to do this? Is there a way to use "ps" to get the PID I am missing? Is there a way to store the data from "ps -ef | grep "myprogram" so that I can draw the PIDs out of it? (My program runs as parent and child.) Is there a way to force a user name onto the cron job for easy identification?