Search code examples
bashsudognu-coreutils

Running a delayed command with 'sudo'


I want run a Bash script as root, but delayed. How can I achieve this?

sudo "sleep 3600; command" , or
sudo (sleep 3600; command)

does not work.


Solution

  • You can use at:

    sudo at next hour
    

    And then you have to enter the command and close the file with Ctrl+D. Alternatively you can specify commands to be run in a file:

    sudo at -f commands next hour