Run command `at ` 5 seconds from now

前端 未结 8 1815
甜味超标
甜味超标 2020-12-29 05:03

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\'

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 05:25

    Just to note: in man at, I saw there is a -t switch, which will accept date times with seconds - but unfortunately the seconds will be truncated:

    $ date; date --date="now +10 seconds" +"%m%d%H%M.%S"; echo "logger AAAA" | at -t $(date --date="now +5 seconds" +"%Y%m%d%H%M.%S")
    Thu Feb  5 14:45:57 CET 2015
    02051446.07
    warning: commands will be executed using /bin/sh
    job 8 at Thu Feb  5 14:46:00 2015
    

    ... and so the job may actually be scheduled in the past (also, used logger to syslog, because it doesn't look like echoing to terminals' stdout can work from here)

提交回复
热议问题