{"id":152,"date":"2017-01-18T01:50:30","date_gmt":"2017-01-18T01:50:30","guid":{"rendered":"https:\/\/www.hostingahead.com\/blog\/?p=152"},"modified":"2017-01-18T01:50:30","modified_gmt":"2017-01-18T01:50:30","slug":"avoid-files-created-cron-executed","status":"publish","type":"post","link":"https:\/\/www.hostingahead.com\/blog\/avoid-files-created-cron-executed\/","title":{"rendered":"Avoid files are being created when cron is executed"},"content":{"rendered":"<p>Some times we might have noticed that there are large number of tiny files are created on the home directory with the name of the cron file.\u00a0 For example if your cron url is https:\/\/www.hostingahead.com\/cron\u00a0 your home directory will have files like cron.1, cron.2 etc..<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-153\" src=\"https:\/\/www.hostingahead.com\/blog\/wp-content\/uploads\/2017\/01\/cron.png\" alt=\"Cron Output\" width=\"505\" height=\"438\" srcset=\"https:\/\/www.hostingahead.com\/blog\/wp-content\/uploads\/2017\/01\/cron.png 505w, https:\/\/www.hostingahead.com\/blog\/wp-content\/uploads\/2017\/01\/cron-300x260.png 300w\" sizes=\"(max-width: 505px) 100vw, 505px\" \/><\/p>\n<p>A typical cron command will be like this :<\/p>\n<blockquote><p>wget\u00a0 <a href=\"https:\/\/hostingahead.com\/cron\" target=\"_blank\" rel=\"nofollow\">https:\/\/hostingahead.com\/cron<\/a><\/p><\/blockquote>\n<p>This has two problems. 1) This download the file and save to disk also the notification may be emailed to the user as well. In order to avoid we modify it as below<\/p>\n<blockquote><p>wget -O <a href=\"https:\/\/hostingahead.com\/cron\" target=\"_blank\" rel=\"nofollow\">https:\/\/hostingahead.com\/cron<\/a> &gt; \/dev\/null 2&gt;&amp;1<\/p><\/blockquote>\n<p><strong>More info:<\/strong><br \/>\n&gt; is for redirect<br \/>\n\/dev\/null is a black hole where any data sent, will be discarded<br \/>\n2 is the file descriptor for Standard Error<br \/>\n&gt; is for redirect<br \/>\n&amp; is the symbol for file descriptor (without it, the following 1 would be considered a filename)<br \/>\n1 is the file descriptor for Standard Out<br \/>\nTherefore &gt;\/dev\/null 2&gt;&amp;1 is redirect the output of your program to \/dev\/null. Include both the Standard Error and Standard Out.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some times we might have noticed that there are large number of tiny files are created on the home directory with the name of the cron file.\u00a0 For example if your cron url is https:\/\/www.hostingahead.com\/cron\u00a0 your home directory will have files like cron.1, cron.2 etc.. A typical cron command will be like this : wget\u00a0 &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1,3],"tags":[23,24],"_links":{"self":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/152"}],"collection":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/comments?post=152"}],"version-history":[{"count":1,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":154,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/152\/revisions\/154"}],"wp:attachment":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/media?parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/categories?post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/tags?post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}