简体   繁体   English

如何使用shell_exec或exec创建crontab?

[英]How to create crontab using shell_exec or exec?

Hello I am trying for the first time to use the crontab without using the terminal but only PHP file. 您好,我是第一次尝试不使用终端而是仅使用PHP文件而不使用crontab。 I'm working locally with MAMP on mac. 我在Mac上使用MAMP在本地工作。 Am I doing something wrong? 难道我做错了什么?

<?php
$path= dirname(__FILE__);
shell_exec("crontab -e");
shell_exec("crontab */1 * * * * php ".$path."/run.php");

in run.php i would write a text file! 在run.php我会写一个文本文件! Grazie ciao 格拉齐·乔

看到这里: http : //www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/所以我想你可以把文件放到一个该文件夹的内容类似于“ * / 1 * * * * php”。$ path。“ / run.php”,仅此而已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM