Large computational tasks consume time and computational resources, therefore I am looking for a way to execute them in a specified time window using a shell script.

I want to run the script batch.sh during idle hours (2AM-6AM) and continue on the following day from where it left off.

Right now I'm using a combination of three one-line commands, is it possible to fully automate the time scheduling?

The original script that starts luajit with caffeinate:

caffeinate -i ./batch.sh

Command to pause the script (should run at 6AM):

kill -TSTP `pgrep luajit | cut -d' ' -f2`

Command to resume the script (should run at 2AM):

kill -CONT `pgrep luajit | cut -d' ' -f2`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.