操作系统
操作系统相关知识及技巧

PandoraBox定时任务

  • 启动cron服务:
/etc/init.d/cron start
  • 重新启动cron服务:
/etc/init.d/cron restart
  • 查看任务
crontab  -l
  • 编辑任务
crontab  -e   //使用a或i进入编辑模式,编辑完成后按ESC,输入:wq保存文件
  • 每2分钟打开网页,不保存
*/2 * * * * /usr/bin/wget --output-document=/dev/null http://zhaoxugeng.cn/***.php
//需要注意文件格式、空格字符等
  • 定时语法

    • 分 时 天 月 星期几 命令
    • * :表示任意的时刻;如小时位 * 则表示每个小时
    • n :表示特定的时刻;如小时位 5 就表示5时
    • n,m :表示特定的几个时刻;如小时位 1,10 就表示1时和10时
    • n-m :表示一个时间段;如小时位 1-5 就表示1到5点
    • /n : 表示每隔多少个时间单位执行一次;如小时位 /1 就表示每隔1个小时执行一次命令,也可以写成 1-23/1

ubuntu安装pytz

错误提示:ModuleNotFoundError: No module named 'pytz'

root@VM-16-14-ubuntu:~# easy_install --upgrade pytz
easy_install: command not found

安装easy_install:

root@VM-16-14-ubuntu:~# wget https://bootstrap.pypa.io/ez_setup.py -O - | python

然后执行:

easy_install --upgrade pytz