The command to execute the script later

I would like to execute the script in 12 hours. I could execute the script using remote access, but the problem is that I will travel in flight and may not have Internet access. So I was wondering if there was any command to execute the script in a few hours or at a specific time. eg.

cat my_script.sh
echo Hello World
run my_script.sh at 23:00 hr
+4
source share
4 answers

Take a look at the manual page for at

man at

There are many ways to indicate the time. You can do something like:

at -f my_script.sh 23:00
+6
source

Use the cron job in linux. as

0 */12 1 11 3 /bin/execute/my/script.sh >/dev/null 2>&1
+4
source
#!/usr/bin/python
import time
time.sleep(60*60*12)
# your script here

# for shell script:
import subprocess
subprocess.call(['./my_script_name.sh'])

, , , .sh script shebang script #!/usr/bin/env bash $ chmod 744 my_script.sh

+2

I would recommend using cronor atfor this kind of operation. If you need to run the task only once, then atthe easiest option will be.

If you prefer to run it on a periodic basis / schedule (for example, if you need it to work every night), it is more flexible with cronthe tool you are looking for.

Have a safe trip!

+1
source

Source: https://habr.com/ru/post/1688848/


All Articles