{"id":505,"date":"2009-02-17T11:44:02","date_gmt":"2009-02-17T16:44:02","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=505"},"modified":"2016-02-25T16:02:44","modified_gmt":"2016-02-25T21:02:44","slug":"cron-job","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=505","title":{"rendered":"Cron Job"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Cron_Job\">Cron Job<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Syntax\">Syntax<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Examples\">Examples<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Every_3:15_am_from_Monday_to_Friday\">Every 3:15 am from Monday to Friday<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Every_five_minutes\">Every five minutes<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Every_First_and_Third_Sunday_at_1_am\">Every First and Third Sunday at 1 am<\/a>\n\t\t\t<\/li>\n<\/ol>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Cron_Job\"><h2>Cron Job<\/h2><\/span>\n<p>* Don&#8217;t forget to set env when calling shell script from cron job.<\/p>\n<pre lang=\"bash\">\r\n# Create\/edit crontab file\r\ncrontab -e\r\n\r\n# List crontab file\r\ncrontab -l\r\n\r\n# Remove crontab file\r\ncrontab -r\r\n<\/pre>\n<span id=\"Syntax\"><h2>Syntax<\/h2><\/span>\n<pre lang=\"bash\">\r\n* * * * *  command to execute\r\nmin(0-59)\r\nhr(0-23)\r\nday of month(1-31)\r\nmonth of year(1-12)\r\nday of wk(0-6 with 0=Sunday)\r\n<\/pre>\n<p><strong>*<\/strong> = all possible values<\/p>\n<span id=\"Examples\"><h2>Examples<\/h2><\/span>\n<span id=\"Every_3:15_am_from_Monday_to_Friday\"><h3>Every 3:15 am from Monday to Friday<\/h3><\/span>\n<pre lang=\"bash\">\r\n15 3 * * 1-5 find $HOME -name core 2>\/dev\/null | xarg rm -f\r\n<\/pre>\n<span id=\"Every_five_minutes\"><h3>Every five minutes<\/h3><\/span>\n<pre lang=\"bash\">\r\n*\/5 * * * * echo 'hello world'\r\n<\/pre>\n<span id=\"Every_First_and_Third_Sunday_at_1_am\"><h3>Every First and Third Sunday at 1 am<\/h3><\/span>\n<pre lang=\"bash\">\r\n0 1 1-7,15-21 * * [ `date +\\%u` = 0 ] && \/path\/to\/my_script.sh >> \/path\/to\/my_script.log 2>&1\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Cron Job * Don&#8217;t forget to set env when calling shell script from cron job. # Create\/edit crontab file crontab -e # List crontab file crontab -l # Remove crontab file crontab -r Syntax * * * * * command &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=505\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[45],"tags":[],"class_list":["post-505","post","type-post","status-publish","format-standard","hentry","category-solaris"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-89","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=505"}],"version-history":[{"count":4,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":11337,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/505\/revisions\/11337"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}