perl环境参考
Crontab参考
Docker 定时器参考
下载R语言
wget
解压R
tar -xf R-3.2.2.tar.gz
编写Dockerfile
FROM ubuntu:14.04
RUN apt-get update -y
RUN apt-get install -y perl build-essential gfortran python-pip wget
#移入R
ADD R-3.2.2 /home/R
#安装apt-get repo
RUN apt-get -y install software-properties-common
RUN add-apt-repository ppa:gluster/glusterfs-3.5
RUN apt-get update -y
RUN apt-get install -y libpng-dev libtiff-dev
RUN apt-get install -y libreadline-dev
RUN apt-get install -y libXt-dev
RUN export PKG_CONFIG_PATH=/usr/lib/pkgconfig/
#编译
RUN /home/R/configure --prefix $HOME
RUN make && make install
RUN pip install jieba
#安装程序依赖
RUN apt-get install -y curl
RUN curl -L | perl - --sudo App::cpanminus
RUN apt-get install -y libmysql++-dev
RUN cpanm DBI
RUN cpanm DBD::mysql
RUN cpanm Redis
RUN cpanm JSON::XS
RUN cpanm File::Lockfile
RUN cpanm Date::Calc::XS
RUN cpanm Encode::HanConvert
RUN cpanm Unicode::UTF8
RUN cpanm Statistics::R
#将代码移入
ADD test.pl perl.pl
#增加人物计划
ADD crontab /etc/cron.d/hello-cron
RUN chmod 0644 /etc/cron.d/hello-cron
RUN touch /var/log/cron.log
CMD cron tail -f /var/log/cron.log
编写Cron脚本
*/1 * * * * root echo “Hello Perl” >> /var/log/cron.log 2>&1
*/1 * * * * root perl /perl.pl >> /var/log/cron.log 2>&1
编译
sudo docker build -t lifeix:perl .
运行
docker run -it -d --name perl lifeix:perl
进入容器
docker exec -it perl bash
查看日志
tail -f /var/log/cron.log