I have a python code that generates the command to record a live stream from Ustream.
I want to set a cronjob to run this script once a week to record a show, is there a code I could use in the python code so that after generating the right command it’s executed for a given time and then stop it?
I guess there should be a way to run the script, wait the desire time and then just kill the process using it’s ID. Is that correct?
You could have the started process write its process ID to a file when it starts up. Then make another cron job that reads that file and kills the process ID in that file.
You could alternatively (rather than modifying the started process) make a ‘starter’ bash script which writes the started process’s ID to a file:
Then, to kill it: