使用 window 服务触发 php 文件

Trigger a php file using window service

我的服务器中有一个 php 文件用来发送邮件。我想在一天中的特定时间触发该文件以发送邮件。所以我计划为 trigger.But 创建一个 window 服务,我不知道该怎么做以及如何在 window 服务中提及 URL。因此,如果您分享任何链接或想法,这对我更有帮助。

Create/Run 使用 ssh 的 cron 作业:

使用 ssh 登录服务器..

type crontab -e
*/1 * * * * php SCRIPT_NAME --> this will run every minute
00 00 * * * php SCRIPT_NAME --> this will run at 12 AM every day
*/5 * * * * php SCRIPT_NAME -> every 5 minutes
if its giving you an option to select editor after crontab -e command, then select vim or vim basic
(To run python scripts replace php with python e.g. */1 * * * * python SCRIPT_NAME --> this will run every minute)
7,22,37,52 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1 ---> cron will run on 7th, 22nd, 37th and 52nd min of every hour

如果你想从 C# 调用一个网站,你只需要

WebRequest webRequest = WebRequest.Create("URL_HERE");
WebResponse webResp = webRequest.GetResponse();

将上面示例中的 URL_HERE 替换为您的 URL。