1

I wish to run a command for the longest period possible and kill it at a certain absolute time (if it is still running), something like:

killat "2018-06-09_23:55" ./myscript.bash

The resources I've found relate to killing processes at a time relative to the start time.

The timeout command takes an argument for the numbers of seconds after which to kill the process, but this is also relative to the start time. One solution would be to calculate the difference between now and the desired time and pass that to timeout.

Another way might be to set up a one-off cron job at the required time that looks for a recorded PID and send a kill signal.

Are there any purpose build alternatives to this?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.