/** * Install a cron job that runs at a custom time (other than the .hourly/ * .daily/.weekly/.monthly. A file in the same format as /etc/crontab is * created in /etc/cron.d with permissions 644. * * $fileName should not have any extension and is the name of the file that * wil be created in $cronPath. * * $time is a string that represents the customary cron time format: * minute hour day month dayofweek * * minute - any integer from 0 to 59 * hour - any integer from 0 to 23 * day - any integer from 1 to 31 (must be a valid day if a month is * specified) * month - any integer from 1 to 12 (or the short name of the month such * as jan or feb) * dayofweek - any integer from 0 to 7, where 0 or 7 represents Sunday (or * the short name of the week such as sun or mon) * * Example: run the command at 7 am every day * 0 7 * * * * * $sfTaskCall is the symfony command line that the script should execute. * * @param <type> $cronPath Path to the cron directory (must be /etc/cron.d) * @param <type> $fileName Name of the file to be created in $cronPath * @param <type> $time Cron time format (see above) * @param <type> $sfTaskCall The command to call */ public static function custom($fileName, $time, $sfTaskCall, $cronPath = '/etc/cron.d') { $DS = DIRECTORY_SEPARATOR; $fullPath = $cronPath . $DS . $fileName; $command = $time . ' root php ' . sfConfig::get('sf_root_dir') . $DS . $sfTaskCall . PHP_EOL; uFs::file_put_contents($fullPath, $command); uFs::chmod($fullPath, 0644, true); }
/** * Copy a file * * @param string $newFullPath The full path of the copied file * @return string */ public function copy($newFullPath) { $contents = uFs::file_get_contents($this->fullPath); uFs::file_put_contents($newFullPath, $contents); $this->setFileName($newFullPath); return $newFullPath; }