[請益] 不好意思我有一個關於php的問題

看板PHP作者 (RayShigeno)時間9年前 (2016/01/15 16:02), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
各位好 關於這個類別 class Crontab { // In this class, array instead of string would be the standard input / output format. // Legacy way to add a job: // $output = shell_exec('(crontab -l; echo "'.$job.'") | crontab -'); static private function stringToArray($jobs = '') { $array = explode("\r\n", trim($jobs)); // trim() gets rid of the last \r\n foreach ($array as $key => $item) { if ($item == '') { unset($array[$key]); } } return $array; } static private function arrayToString($jobs = array()) { $string = implode("\r\n", $jobs); return $string; } static public function getJobs() { $output = shell_exec('crontab -l'); return self::stringToArray($output); } static public function saveJobs($jobs = array()) { $output = shell_exec('echo "'.self::arrayToString($jobs).'" | crontab -'); return $output; } static public function doesJobExist($job = '') { $jobs = self::getJobs(); if (in_array($job, $jobs)) { return true; } else { return false; } } static public function addJob($job = '') { if (self::doesJobExist($job)) { return false; } else { $jobs = self::getJobs(); $jobs[] = $job; return self::saveJobs($jobs); } } static public function removeJob($job = '') { if (self::doesJobExist($job)) { $jobs = self::getJobs(); unset($jobs[array_search($job, $jobs)]); return self::saveJobs($jobs); } else { return false; } } } 在這邊附上網址 http://www.kavoir.com/2011/10/php-crontab-class-to-add-and-remove-cron-jobs.html 因為完全沒學過php 但目前需要用到 想問各位 如果我想要增加一個例如: 30 14 * * * sudo python timeopen.py這個任務 我在php網頁需要打甚麼code啊QQ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.73.9.234 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1452844928.A.382.html

01/15 18:08, , 1F
阿裏面不是一直在呼喚Jobs 這麼愛Jobs你就照著呼一下阿
01/15 18:08, 1F
文章代碼(AID): #1McAU0E2 (PHP)
文章代碼(AID): #1McAU0E2 (PHP)