Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 4
    Have a look at at (one-time execution). Commented Oct 2, 2018 at 10:14
  • 16
    I haven't done this, but your login script could start a sudo shutdown -h +60 which would start a countdown counter of 60 mins for the shutdown (-halt) process. If you wanted to cancel it, you could sudo shutdown -c (this doesn't use cron though) Commented Oct 2, 2018 at 10:20
  • 7
    Depending on the nature of your tasks maybe it's worth running them inside a docker container, so you don't need to worry about switching off a server. The container is created, it runs your tasks, and it's destroyed after that. Commented Oct 2, 2018 at 11:50
  • 1
    Have you looked into uptime? You could have a periodic cron job that checks uptime and if the value is > 1hr then initiate init 0. You could also check ps -ef to see if your process is still running. Commented Oct 3, 2018 at 5:58
  • 1
    Why not shut it down when your tasks are done, rather than after some fixed amount of time? Commented Oct 3, 2018 at 15:21