{"id":501,"date":"2021-02-16T15:13:30","date_gmt":"2021-02-16T15:13:30","guid":{"rendered":"https:\/\/www.larry4u.com\/co2diy.com\/?page_id=501"},"modified":"2023-09-28T14:28:39","modified_gmt":"2023-09-28T14:28:39","slug":"crontab","status":"publish","type":"page","link":"https:\/\/www.larry4u.com\/co2diy.com\/crontab\/","title":{"rendered":"CronTab"},"content":{"rendered":"<p>The Crontab is the way we control what programs we want to run in the background.<\/p>\n<p>Here is a link on how it works: <a href=\"https:\/\/crontab.guru\/\" target=\"_blank\" rel=\"noopener\">Crontab.guru &#8211; The cron schedule expression editor<\/a><\/p>\n<p>We are going to add the following lines to the crontab:<\/p>\n<ul>\n<li>\n<pre>*\/3 * * * * python \/home\/aranet\/getAranetData.py (MAC address) &gt; \/home\/aranet\/aranet.txt\r\n*\/1 * * * * python \/aranet\/coPng.py &gt; \/home\/aranet\/coPng.log\r\n1 1 * * * python \/home\/aranet\/clean_data_folder.py &gt; \/home\/pi\/clean.log<\/pre>\n<\/li>\n<\/ul>\n<p>You now will need to use the Linux editor nano or vi.\u00a0 nano is more user friendly<\/p>\n<p>in the \/home\/aranet directory type crontab -e (this will only come up the first time you run crontab -e)<\/p>\n<p>you will see:<\/p>\n<p style=\"padding-left: 40px;\">Select an editor. To change later, run &#8216;select-editor&#8217;.<br \/>\n1. \/bin\/nano &lt;&#8212;- easiest<br \/>\n2. \/usr\/bin\/vim.tiny<br \/>\n3. \/bin\/ed<\/p>\n<p>if using nano type 1<\/p>\n<p>You now will see<\/p>\n<p style=\"padding-left: 40px;\"># Edit this file to introduce tasks to be run by cron.<br \/>\n#<br \/>\n# Each task to run has to be defined through a single line<br \/>\n# indicating with different fields when the task will be run<br \/>\n# and what command to run for the task<br \/>\n#<br \/>\n# To define the time, you can provide concrete values for<br \/>\n# minute (m), hour (h), day of the month (dom), month (mon),<br \/>\n# and day of the week (dow) or use &#8216;*&#8217; in these fields (for &#8216;any&#8217;).<br \/>\n#<br \/>\n# Notice that tasks will be started based on the cron&#8217;s system<br \/>\n# daemon&#8217;s notion of time and timezones.<br \/>\n#<br \/>\n# Output of the crontab jobs (including errors) is sent through<br \/>\n# email to the user the crontab file belongs to (unless redirected).<br \/>\n#<br \/>\n# For example, you can run a backup of all your user accounts<br \/>\n# at 5 a.m every week with:<br \/>\n# 0 5 * * 1 tar -zcf \/var\/backups\/home.tgz \/home\/<br \/>\n#<br \/>\n# For more information, see the manual pages of crontab(5) and cron(8)<br \/>\n#<br \/>\n# m h dom mon dow command<\/p>\n<p style=\"padding-left: 40px;\">Now just add the above to\u00a0 the bottom of the file:<\/p>\n<p>now save the file<\/p>\n<p>to verify that all is well-run crontab -l (that is a little L, which stands for a list, a -e stans for edit)<\/p>\n<p>notice the 1 1 * * * in the last line.\u00a0 That means it will run every day, 1 minute after 1 AM<span style=\"background-color: white; color: black;\">.<\/span><\/p>\n<p>The others will run every minute. if you want to run every 2 minutes, then It would be *\/2 * * * *<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.larry4u.com\/co2diy.com\/display-data-via-web-page\/\">Next<\/a>, display data via a web page<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Crontab is the way we control what programs we want to run in the background. Here is a link on how it works: Crontab.guru &#8211; The cron schedule expression editor We are going to add the following lines to <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/www.larry4u.com\/co2diy.com\/crontab\/\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":""},"_links":{"self":[{"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/pages\/501"}],"collection":[{"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/comments?post=501"}],"version-history":[{"count":17,"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/pages\/501\/revisions"}],"predecessor-version":[{"id":505,"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/pages\/501\/revisions\/505"}],"wp:attachment":[{"href":"https:\/\/www.larry4u.com\/co2diy.com\/wp-json\/wp\/v2\/media?parent=501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}