solution for scheduled uploads - cron job?

Deadly 提交于 2019-12-25 05:27:10

问题


I'm trying to find the best solution for scheduling uploads to my server to specific directories.

  1. initially uploading the content
  2. pushing it live at the defined time

I've heard cron job recommended, but I've no idea how to use such a thing.

I'm trying to upload .html, .php, and .jpg files to multiple different directories all at the same future time.

I'm using Linux, cPanel, PHP. Typical LAMP stack + cPanel.

Any input is appreciated.


回答1:


cron is really easy. To edit the jobs type

crontab -e

This will give you a blank file with comments explaining its structure. You use numbers with wild cards to say when to run things, and then what to run. For example, from this page,

   # run five minutes after midnight, every day
   5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
   # run at 2:15pm on the first of every month -- output mailed to paul
   15 14 1 * *     $HOME/bin/monthly
   # run at 10 pm on weekdays, annoy Joe
   0 22 * * 1-5    mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
   23 0-23/2 * * * echo "run 23 minutes after midn, 2am,

cron will run the command regularly. If you just want it to run once, you need at. See here e.g.

at -f myscript.sh 2:00 july 13



回答2:


You put this in your cron, this code will run your script for every 3 hours. And in your PHP script you can have there rename function which is moving the files in your target path.

* 3 * * * sudo -u www-data php5 /my/php/script.php


来源:https://stackoverflow.com/questions/18012074/solution-for-scheduled-uploads-cron-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!