As part of a slightly complex script, I need to tell a server to run a simulation. Normally, I would achieve this by doing ssh user@server 'simulation/script'. However, doing so would keep the ssh session alive until 'simulation/script' is done, which is undesirable to me.
I recently learned about the at command, and it seems to fit into my problem well.
What I want to do now is to ssh into my server, and at my simulation script to run in 5 seconds (more than enough time for the ssh connection to be closed). Thus, once the ssh connection is closed within 5 seconds, the server will start the simulation without needing the ssh connection to stay alive.
What I’m having trouble with is the time expression that at needs in order to schedule a job “5 seconds from now”
I have tried the following time expressions, all of which give me errors:
now + 5 seconds
now + 5 sec
now + 5 s
now + 5seconds
now + 5sec
now + 5 s
now+5sec
now+5seconds
now+5s
How can I get my at to run my command “5 seconds from now”?
There’s no seconds in at :
man atsaid :So instead of
at, you could use asleepI think.See
man 1 sleepIf you’d like to run
ssh user@server 'simulation/script'without waiting, simply do :the command will run in the background.
Moreover, as Rawkode said,
nohupwill help there.So finally :
with nohup, you can quit your terminal and have the
sshprocess alive.EDIT: if you want to run thesshcommand and close the connection :