时时商务社区

标题: linux下实现定时执行php脚本 [打印本页]

作者: xgnic    时间: 2018-2-14 05:49

            在linux中输入命令
[U]复制代码[/U] 代码如下:
crontab -e
然后使用vim的命令编辑打开的文件,输入
[U]复制代码[/U] 代码如下:
0 * * * * /usr/bin/php -f /home/userxxx/update.php
保存,退出,好了,现在系统会在每个0点自动执行update.php脚本,脚本中可以编写数据库执行,自动发邮件等功能。
注:直接写成 0 * * * * php -f /home/userxxx/update.php将不会起作用。
另外cronjob的格式为:
MIN HOUR DOM MON DOW CMD

      Field
      Description
      Allowed Value
   
   
      MIN
      Minute field
      0 to 59
   
   
      HOUR
      Hour field
      0 to 23
   
   
      DOM
      Day of Month
      1-31
   
   
      MON
      Month field
      1-12
   
   
      DOW
      Day Of Week
      0-6(0表示星期天)
   
   
      CMD
      Command
      Any command to be executed.
   
使用(-)可以划定范围
如:0 0-6 * * * command 表示每天0-6点整执行command
使用(,)可以枚举时间
如: 0,15,30,45 * * * * command 表示每个小时的0分,15分,45分,30分会执行command
使用(/)可以指定间隔
如:* */4 * * * command表示每四小时执行command
组合用法
0-10/2 * * * * command表示在前10分钟内每隔2分钟执行command
            
            
您可能感兴趣的文章:
  • linux下用cron定时执行任务的方法
  • 如何使用Linux的Crontab定时执行PHP脚本的方法
  • Linux操作系统定时调度系统Cron深入介绍
  • linux使用select实现精确定时器详解
  • linux实现php定时执行cron任务详解
  • linux使用crontab实现PHP执行计划定时任务
  • linux下使用crontab实现定时PHP计划任务失败的原因分析
  • Linux shell实现每天定时备份mysql数据库
  • 服务器定时执行计划任务,定时访问页面(windows/linux)
  • linux系统下定时执行php脚本的方法
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2