开发者

Cron job to put files on server

Let me start by saying that I know nothing about Cron, so sorry. How can I make a php or perl script get files from my computer and upload them to my web server everyday at midnight?

The webserver is linux. The computer from which开发者_Go百科 the files need to be retrieved is Windows.


Cron will start a script or run a command on the local computer (the computer running cron) at regular intervals. If you can run a script on your computer that will upload files to your webserver, then cron can schedule that script to run at midnight every night. (Assuming you're running an operating system that has cron or something cron-like.) Cron will not, however, help you write the script to upload the files.


One solution would be to put an FTP server on your server and use the FTP functions PHP has to upload (using FTP ofcourse) from your computer to the server.
I assume it is obvious there are "some" security issues with approach you should take extra care to handle.


Assuming you are running Linux, the below commands will show you the relevant manual pages:

man cron      # man page for cron
man 1 crontab # man page for "crontab" program that installs and edits crontabs
man 5 crontab # man page for cron schedule files (called "crontabs")

Basically, cron runs commands from a schedule. The schedule is called a "crontab", and the command that installs and edits them is also called a "crontab". You could use

crontab -e

to edit your crontab in an editor. Or you could create a crontab file and then just install it using

crontab file_to_use_as_crontab

To see your current crontab, use

crontab -l

The crontab file format can be cryptic. The below example crontab executes /fully/qualified/path/to/script_that_copies_files every day at midnight. Fully qualifying the path to your script is recommended.

# minute hour day month dayofweek
0 0 * * * /fully/qualified/path/to/script_that_copies_files
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜