douao8204 2011-06-20 23:26
浏览 40
已采纳

仅使用Cron执行PHP文件

I've got a PHP script that needs to be executed once a day, at 3:05am Pacific time. I've currently got the script in the root of my site (as in, http://example.com/script.php), and as such, it's executable by anyone who navigates to it in their browser. My server is laid out like this:

/home/[user]/example.com/

Where the example.com folder is the root of that domain. I read the other thread about this:

PHP & cron: security issues

where it was said that I should move the script outside the public directory, so in my case I would move it to the [user] folder. Currently my Cron job command looks like this:

/usr/local/php5/bin/php /home/[user]/example.com/script.php

(I'm using pseudo-names of course.) Would I simply move the file and change the command to:

/usr/local/php5/bin/php /home/[user]/script.php

And it would run normally, yet be unavailable to the public? Since the script is already running through Cron, it's already set up using absolute paths (instead of relative ones) to the files that it needs to include, so this should be a simple move and edit, right?

  • 写回答

3条回答

  • dongqidi2799 2011-08-05 04:19
    关注

    What I ended up doing was just moving it out of the public directory, into my home folder. CRON is still able to access and execute it from there. Thanks for the help guys.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题