将文件放到服务器上的 Cron 作业
首先我要说的是,我对 Cron 一无所知,很抱歉。如何让 php 或 perl 脚本从我的计算机获取文件并每天午夜将它们上传到我的网络服务器?
网络服务器是linux。需要从中检索文件的计算机是Windows。
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 the files need to be retrieved is Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Cron 将定期在本地计算机(运行 cron 的计算机)上启动脚本或运行命令。如果您可以在计算机上运行一个脚本来将文件上传到您的网络服务器,那么 cron 可以安排该脚本在每晚午夜运行。 (假设您正在运行具有 cron 或类似 cron 的操作系统。)但是,Cron 不会帮助您编写上传文件的脚本。
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.
一种解决方案是在您的服务器上放置一个 FTP 服务器,并使用 PHP 必须将(当然使用 FTP)从您的计算机上传到服务器的 FTP 功能。
我认为很明显,您应该格外小心处理方法中存在“一些”安全问题。
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.
假设您运行的是 Linux,以下命令将向您显示相关的手册页:
基本上,cron 按计划运行命令。该计划称为“crontab”,安装和编辑它们的命令也称为“crontab”。您可以使用
编辑器来编辑 crontab。或者您可以创建一个 crontab 文件,然后使用以下命令安装它。
要查看当前的 crontab,请使用
crontab 文件格式可能很神秘。下面的示例 crontab 每天午夜执行 /complete/qualified/path/to/script_that_copies_files。建议完全限定脚本的路径。
Assuming you are running Linux, the below commands will show you the relevant manual pages:
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
to edit your crontab in an editor. Or you could create a crontab file and then just install it using
To see your current crontab, use
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.