为了简单起见,我如何创build一个将在11:57 PM运行的cron并在屏幕上打印“Hello”然后删除它自己? (Cent OS 5)
如果你只需要运行一次,cron不是你的工具。
at (1) - queue, examine or delete jobs for later execution
例如:
# at 12:57PM warning: commands will be executed using /bin/sh at> echo hello at> <EOT> job 2 at Mon Jan 2 12:57:00 2012
(完成input命令后按ctrl + d)
相对于现在的调度
fbh@pinky:~$ at now + 5 min warning: commands will be executed using /bin/sh at> echo moo at> <EOT> job 5 at Mon Jan 2 06:05:00 2012
和往常一样,阅读更多关于如何在手册页中使用这个工具。
如果你使用at ,命令的输出将通过电子邮件发送给你。 要将文本输出到当前terminal,请执行以下操作:
echo "echo 'hello' > `tty`" | at 11:57PM echo "echo 'hello' > `tty`" | at now + 5 minutes
请注意,当您现在使用+ x分钟时 ,执行时间将被舍入到前一分钟。