I'm trying to find the best solution for scheduling uploads to my server to specific directories.
- initially uploading the content
- 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.
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
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