您的位置:首页 > 其它

运行Perl程序

2015-12-04 11:11 323 查看
perl环境参考http://www.confluence.oa.com/pages/viewpage.action?pageId=7077984

Crontab参考http://linuxtools-rst.readthedocs.org/zh_CN/latest/tool/crontab.html

Docker 定时器参考http://xiaorui.cc/2015/08/14/docker%E4%B8%8B%E8%AE%A1%E5%88%92%E4%BB%BB%E5%8A%A1crontab%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95python/?utm_source=tuicool

下载R语言

wget http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz

解压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 http://cpanmin.us | 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: