目的是把R处理后的数据塞到数据库里面,需要在服务器上设置定时任务~
安装
网上有这种安装方式,但是我没有安装成功。
找不到此安装包~
另外运维在搞服务器的时候好像就已经搞好这个了~
yum -y install vixie-cron
yum -y install crontabs
文件格式
文件格式类似于yarn和trainer配置任务的方式,在tc还是学到蛮多东西的嘛~
分别是分、时、天、月、周几参数
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
设置定时任务
在/etc/下的crontab文件中添加命令:
16 18 * * 6 root Rscript root/Documents/try.R
即每个周六的18点16分执行root/Documents下的try.R文件
x =1:5
write.csv(x,"/root/Documents/try.csv")[root@fengkong1 Documents]
可以在/root/Documents下看到生成csv文件
##PS
google搜索的准确度可好多了~好歹是解决问题咯