vps贴吧云签到cron设置

  • 12
  • 14,125 views
  • A+
所属分类:Linux

昨天在vps上搭了无名智者的贴吧云签到,程序装好还要添加根目录的do.php到计划任务。在官网上看各平台的教程都有,唯独linux的vps没有。只能自己加了,这里把计划任务添加到cron设置里就行了。

第一种:直接用crontab -e

进入之后,按”i”键编辑,添加下面这行(注意空格)不同域名路径稍有不同

* * * * * /usr/local/php/bin/php /home/wwwroot/cmsky.com/web/do.php
例如vestacp面板下为
* * * * * php /home/admin/web/cmsky.com/public_html/do.php

按返回键esc退出编辑,:wq 保存退出,然后重启服务/etc/init.d/crond restart

root查看自己的cron设置:crontab -u root -l  删除crontab -u root -r

第二种:编辑/etc/crontab文件

vi /etc/crontab

* * * * * root php /home/wwwroot/cmsky.com/web/do.php >/dev/null 2>&1

:wq
要是web服务是www一类的用户运行的把root改成那个用户,然后重启服务/etc/init.d/crond restart

查看日志cat /var/log/cron

vim /etc/crontab 与crontab -e写入的定时运行有什么区别?
vim /etc/crontab:是系统级别定义的crontab,/etc/crontab的所有者和组都是root
crontab -e :是用户自定义的crontab,是所有的用户都可以写入的
两种方法记录的位置不一样,一个在/etc/ 另一个在/var/ 里面。都被cron服务调用

你也可以将这个服务在系统启动的时候自动启动:

在/etc/rc.d/rc.local这个脚本的末尾加上:

/sbin/service crond start

weinxin
我的微信公众号
我的微信公众号扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:12   其中:访客  0   博主  0

    • 凉拌炒蛋炒饭 凉拌炒蛋炒饭 4

      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

      我用的是网站监控

        • 厘米 厘米 9

          Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

          @凉拌炒蛋炒饭 我是折腾呢,话说我明天要配同学去配台万元机,准备上卡吧标配了!

        • Javen Javen 3

          Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

          你再不写VPS的教程我就写啦!

            • 厘米 厘米 9

              Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

              @Javen 你写吧,你搭建的是最新版的写的应该更适用~

            • ccccc ccccc 1

              Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

              博主,我用的是debianvps,我设置了按时运行,不过还是没有自动签到……该怎么解决?
              */5 * * * * /var/www/tbqd/do.php

                • 厘米 厘米 9

                  Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                  @ccccc service crond restart没有,不行就用http监控也行!

                    • ccccc ccccc 1

                      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                      @厘米 我现在写了一个脚本来运行do.php,cron来定时运行脚本,这样才能成功

                        • 厘米 厘米 9

                          Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                          @ccccc 你手动php …/do.php能成功吗?

                            • ccccc ccccc 1

                              Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                              @厘米 手动php可以成功,在终端也能成功,就是定时任务没运行

                                • 厘米 厘米 9

                                  Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                                  @ccccc 那好奇怪~

                                  • 迎風别葉index 迎風别葉index 1

                                    Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                                    @ccccc 很奇怪,试了用你这种方法也不行 = =

                          • 迎風别葉index 迎風别葉index 1

                            Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                            懵逼啊,换了个搬瓦工的vps也搭个云签,定时任务根本就不起作用,写个小脚本每一分钟往/data/test.txt 写Hello也不起作用 = =