phillipsdata / tictock

An OS independent task scheduler
MIT License
1 stars 1 forks source link

Add ability to list tasks #2

Open clphillips opened 9 years ago

clphillips commented 9 years ago

The interface for this could be:

use Tictock\Scheduler\SchedulerFactory;

$factory = new SchedulerFactory();
$scheduler = $factory->create();

$scheduler->scheduled(); // returns array of commands (strings)

$scheduler->scheduled() could also accept a parameter to search for a command (as a regular expression):

$scheduler->scheduled('#user/bin/php /path/to/index\.php#i'); // returns an array of commands that match

On *nix:

crontab -l

NOTE: Items in the crontab may be disabled by being commented out (#), so this should be taken into consideration.

On Windows:

schtasks /query /v /fo CSV
clphillips commented 8 years ago

On Windows the task name is used to manage the task (i.e. delete it later). So the Windows implementation should return a key/value array, where each key is the task name and the value is the string command.

*nix would return a numerical array.

clphillips commented 8 years ago

On Windows Vista and up, results in CSV format are returned with additional headers (one additional header for each directory traversed). For example:

"HostName","TaskName","Next Run Time","Status","Logon Mode","Last Run Time","Last Result","Author","Task To Run","Start In","Comment","Scheduled Task State","Idle Time","Power Management","Run As User","Delete Task If Not Rescheduled","Stop Task If Runs X Hours and X Mins","Schedule","Schedule Type","Start Time","Start Date","End Date","Days","Months","Repeat: Every","Repeat: Until: Time","Repeat: Until: Duration","Repeat: Stop If Still Running"
...
"HostName","TaskName","Next Run Time","Status","Logon Mode","Last Run Time","Last Result","Author","Task To Run","Start In","Comment","Scheduled Task State","Idle Time","Power Management","Run As User","Delete Task If Not Rescheduled","Stop Task If Runs X Hours and X Mins","Schedule","Schedule Type","Start Time","Start Date","End Date","Days","Months","Repeat: Every","Repeat: Until: Time","Repeat: Until: Duration","Repeat: Stop If Still Running"
...
"HostName","TaskName","Next Run Time","Status","Logon Mode","Last Run Time","Last Result","Author","Task To Run","Start In","Comment","Scheduled Task State","Idle Time","Power Management","Run As User","Delete Task If Not Rescheduled","Stop Task If Runs X Hours and X Mins","Schedule","Schedule Type","Start Time","Start Date","End Date","Days","Months","Repeat: Every","Repeat: Until: Time","Repeat: Until: Duration","Repeat: Stop If Still Running"

Windows, likewise to *nix, should ignore disabled tasks.