Linux:后台命令crontab、at

1、crontab使用举例

每天23:00向/tmp/datecon.log文件中写入系统日期

kevin@kevin:/opt/d00148588$ crontab -l
no crontab for kevin
kevin@kevin:/opt/d00148588$ crontab -e
no crontab for kevin - using an empty one 
 
Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/emacs23
  4. /usr/bin/vim.basic
  5. /usr/bin/vim.tiny 
 
Choose 1-5 [2]: 5
crontab: installing new crontab
kevin@kevin:/opt/d00148588$ crontab -l
# m h  dom mon dow   command
00 23 * * * /bin/date > /tmp/datecron.log 
 
kevin@kevin:/opt/d00148588$ 

删除crontab文件:

kevin@kevin:/opt/d00148588$ crontab -r
kevin@kevin:/opt/d00148588$ crontab -l
no crontab for kevin
kevin@kevin:/opt/d00148588$ 

2、at使用举例

23:10向/tmp/dateat.log文件中输入系统日期

kevin@kevin:/opt/d00148588$ at 23:10
warning: commands will be executed using /bin/sh
at> date > /tmp/dateat.log
at> <EOT>
job 3 at Thu Sep 13 23:10:00 2012
kevin@kevin:/opt/d00148588$ at -l
3    Thu Sep 13 23:10:00 2012 a kevin
kevin@kevin:/opt/d00148588$ 
posted @ 2012-09-13 23:15  Socrates  阅读(288)  评论(0编辑  收藏  举报