regex - Validating Crontab Entries with PHP -


what best way validate crontab entry php? should using regex, or external library? i've got php script adds/removes entries crontab file, want have way verify time interval portion in valid format.

hmmm, interesting problem.

if you're going validate it, regex isn't going enough, you'll have parse entry , validate each of scheduling bits. that's because each bit can number, month/day of week string, range (2-7), set (3, 4, saturday), vixie cron-style shortcut (60/5) or combination of above -- single regex approach going hairy, fast.

just using crontab program of vixie cron validate isn't sufficient, because doesn't validate completely! can crontab accept sorts of illegal things.

dave taylor's wicked cool shell scripts (google books link) has sh script partial validation, found discussion interesting. might use or adapt code.

i turned links 2 php classes (whose quality haven't evaluated):

another approach (depending on app needs do) might have php construct crontab entry programatically , insert it, know it's valid, rather try validate untrusted string. need make "build crontab entry" ui, simple if don't need complicated scheduling combinations.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -