六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 108|回复: 0

crontab的helloworld

[复制链接]

升级  0.65%

321

主题

321

主题

321

主题

探花

Rank: 6Rank: 6

积分
1013
 楼主| 发表于 2013-2-5 09:20:50 | 显示全部楼层 |阅读模式
参考http://blogold.chinaunix.net/u/31547/showart_438018.html
和http://www.chinaunix.net/jh/6/271992.html

环境redhat5.4
查看:crontab -l
crontab -u user -e
*/2 * * * * echo "`date` \n " >>/root/Desktop/test/a.txt

前5个代表时间 每隔多长时间就用/
分钟 (0-59)
小時 (0-23)
日期 (1-31)
月份 (1-12)
星期 (0-6)//0代表星期天

------------rsync ssh crontab--------------------------
在client端:
cd ~
cd .ssh
执行
/usr/bin/ssh-keygen  
cat id_rsa.pub > 服务器的/root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

crontab -u root -e
[root@localhost test]# crontab -l
*/2 * * * * echo "`date` \n " >>/root/Desktop/test/a.txt
*/2 * * * * rsync -av /root/Desktop/test/ root@192.168.122.1:/opt/backup/

在服务端用 watch -n 1 cat a.txt跟踪backup下面的a.txt
注意a.txt原来如果有内容将被覆盖
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表