将文件放到服务器上的 Cron 作业

发布于 2024-09-13 01:41:32 字数 120 浏览 2 评论 0原文

首先我要说的是,我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

身边 2024-09-20 01:41:32

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.

GRAY°灰色天空 2024-09-20 01:41:32

一种解决方案是在您的服务器上放置一个 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.

瞳孔里扚悲伤 2024-09-20 01:41:32

假设您运行的是 Linux,以下命令将向您显示相关的手册页:

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")

基本上,cron 按计划运行命令。该计划称为“crontab”,安装和编辑它们的命令也称为“crontab”。您可以使用

crontab -e

编辑器来编辑 crontab。或者您可以创建一个 crontab 文件,然后使用以下命令安装它。

crontab file_to_use_as_crontab

要查看当前的 crontab,请使用

crontab -l

crontab 文件格式可能很神秘。下面的示例 crontab 每天午夜执行 /complete/qualified/path/to/script_that_copies_files。建议完全限定脚本的路径。

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文