{"id":2147,"date":"2020-12-16T13:38:32","date_gmt":"2020-12-16T11:38:32","guid":{"rendered":"https:\/\/www.virtono.com\/community\/?p=2147"},"modified":"2020-12-10T08:49:48","modified_gmt":"2020-12-10T06:49:48","slug":"cron-run-linux-tools-and-commands-at-boot","status":"publish","type":"post","link":"https:\/\/www.virtono.com\/community\/knowledgebase\/cron-run-linux-tools-and-commands-at-boot\/","title":{"rendered":"Cron: Run Linux tools and commands at boot"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The Cron task planner with the variable time specification &#8220;@reboot&#8221; is suitable for scripts and background programs that are to be executed when the system is started.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are tasks under Linux that would be basically simple\u00a0solution but is anything but trivial because of the differences between the Linux distributions.\u00a0This includes starting your own programs and scripts when the system boots.\u00a0Actually, this should always be done via the init daemon with a suitable start script.\u00a0If none is available for the desired purpose, you are forced to write one yourself.\u00a0But there is an easier way.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecchannel.de\/i\/detail\/artikel\/3205434\/1\/2707657\/EL_mediaN10013\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/images.tecchannel.de\/bdb\/2707657\/840x473.jpg?w=750&#038;ssl=1\" alt=\"Easy autostart with the Cron task planner.\" title=\"Easy autostart with the Cron task planner.\"\/><\/a><figcaption>Easy autostart with the Cron task planner.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Debian and Linux distributions derived from it, such as\u00a0Ubuntu\u00a0and\u00a0Raspbian\u00a0, provide the file \u201c\/etc\/rc.local\u201d for their own scripts and programs.\u00a0What is entered there before the final line &#8220;exit 0&#8221; is carried out by the system with root rights during boot.<br><br>The system ignores all errors and skips the rest of the file from the first faulty command so that the information in &#8220;rc.local&#8221; does not affect the system start.\u00a0If something does not work right away, troubleshooting in the &#8220;rc.local&#8221; is therefore difficult.\u00a0And for distributions outside the\u00a0Debian\u00a0family tree, the start method is irrelevant anyway, since there is no \u201crc.local\u201d there.<br><br>A slightly better, also uncomplicated method of running scripts and programs automatically when booting is provided by the Cron task scheduler.\u00a0This supports the keyword &#8220;@reboot&#8221; as time specification, which defines the system start as the time.\u00a0Whether a restart or a cold start does not matter.<br><br>One advantage is that Cron cannot only execute the entered commands as root.\u00a0Every user of the system can put autostart commands in their own cron table, which are then executed in this user context.<br><br>To edit your own cron table, type<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>crontab -e<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">in the terminal.&nbsp;With<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo crontab -e<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">edit cron entries for the root account.&nbsp;In the called editor you define an autostart call with &#8220;@reboot&#8221; at the beginning of the line and the exact path to the script or the program file:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>@reboot [Pfad\/zum\/Befehl]<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As in the rc.local \u201cyou cannot start any graphic applications, not even programs that require a terminal.&nbsp;However, there is a trick with the help of the screen tool to start terminal programs in the background.&nbsp;For example, the line<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>@reboot \/usr\/bin\/screen -d -m rtorrent<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">the bit torrent client rtorrent in a screen session, which you can then use<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>screen -x<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">can bring them to the foreground at any time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Cron task planner with the variable time specification &#8220;@reboot&#8221; is suitable for scripts and background programs that are to be executed when the system is started. There are tasks under Linux that would be basically simple\u00a0solution but is anything but trivial because of the differences between the Linux distributions.\u00a0This<\/p>\n","protected":false},"author":4,"featured_media":2148,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5,3],"tags":[],"class_list":["post-2147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","category-tutorial-how-to"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/cron-jobs.png?fit=800%2C500&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7ISfL-yD","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3392,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/locations-of-common-log-files-on-linux\/","url_meta":{"origin":2147,"position":0},"title":"Locations of Common Log Files on Linux","author":"George B.","date":"May 25, 2023","format":false,"excerpt":"In this tutorial, we will take you on a journey through the labyrinth of directories and unveil the secret locations of common log files on Linux. Whether you're a beginner or an experienced user, this guide will equip you with the knowledge to easily access and analyze these crucial logs.\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/Locations-of-Common-Log-Files-on-Linux.png?fit=600%2C330&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/Locations-of-Common-Log-Files-on-Linux.png?fit=600%2C330&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/Locations-of-Common-Log-Files-on-Linux.png?fit=600%2C330&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2141,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/disposable-linux-set-up-a-secure-system-for-guests\/","url_meta":{"origin":2147,"position":1},"title":"Disposable Linux: Set up a secure system for guests","author":"Shreyash Sharma","date":"December 14, 2020","format":false,"excerpt":"A live system is ideal if guests want to use the Internet or the youngsters do not yet have their own PC to look at holiday photos.\u00a0It does not allow system changes and is therefore also a candidate for secure banking. A live system, and even better a personally adapted\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/xenialpup.jpg?fit=800%2C450&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/xenialpup.jpg?fit=800%2C450&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/xenialpup.jpg?fit=800%2C450&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/xenialpup.jpg?fit=800%2C450&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":876,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/linux-security-the-user-and-superuser-concept-and-how-and-why-it-keeps-your-computer-secure\/","url_meta":{"origin":2147,"position":2},"title":"Linux security : The user and superuser concept and how and why it keeps your computer secure","author":"Daniel Draga","date":"January 24, 2017","format":false,"excerpt":"Security is an important but complex topic. So I'll be doing a series of articles, focusing on the principles and working of security of Linux. The challenge is that it\u2019s an ever-changing idea. Software we think of as secure can become insecure as hackers figure out how to break though\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/01\/unnamed-file.jpg?fit=500%2C590&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1134,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/ubuntu-how-to-use-windows-programs\/","url_meta":{"origin":2147,"position":3},"title":"Ubuntu: How to use Windows programs","author":"Shreyash Sharma","date":"October 21, 2017","format":false,"excerpt":"With the \"Wine\" tool you can use Windows programs under Ubuntu.\u00a0The freeware is free and is constantly developed further.\u00a0Several million users already use the tool.\u00a0We will show you how the program works. The change from XP or another Windows to Ubuntu can fail on many things, but certainly not on\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/freeware-laeuft-ubuntu-linux-mac-bild-screenshot-wine-105171.jpg?fit=598%2C449&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/freeware-laeuft-ubuntu-linux-mac-bild-screenshot-wine-105171.jpg?fit=598%2C449&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/freeware-laeuft-ubuntu-linux-mac-bild-screenshot-wine-105171.jpg?fit=598%2C449&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1370,"url":"https:\/\/www.virtono.com\/community\/internet-and-technology-news\/how-dtrace-could-come-to-linux\/","url_meta":{"origin":2147,"position":4},"title":"How Dtrace could come to Linux","author":"Shreyash Sharma","date":"February 25, 2018","format":false,"excerpt":"Without much notice, Oracle has changed the license of Dtrace.\u00a0The tool adopted by Sun could theoretically be incorporated into the main branch of\u00a0Linux\u00a0.\u00a0This is probably not the case. Already half a year ago Oracle put the license of the kernel module for the analysis tool Dtrace under the GPLv2.\u00a0This is\u00a0what\u00a0Red\u2026","rel":"","context":"In &quot;IT News&quot;","block_context":{"text":"IT News","link":"https:\/\/www.virtono.com\/community\/category\/internet-and-technology-news\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2018\/02\/bcc_tracing_tools_2016.png?fit=1200%2C840&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2018\/02\/bcc_tracing_tools_2016.png?fit=1200%2C840&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2018\/02\/bcc_tracing_tools_2016.png?fit=1200%2C840&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2018\/02\/bcc_tracing_tools_2016.png?fit=1200%2C840&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2018\/02\/bcc_tracing_tools_2016.png?fit=1200%2C840&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1195,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/remove-old-kernels-in-ubuntu\/","url_meta":{"origin":2147,"position":5},"title":"Remove Old Kernels in Ubuntu","author":"Shreyash Sharma","date":"October 27, 2017","format":false,"excerpt":"For\u00a0Ubuntu\u00a0installations (prior to Ubuntu version 15.10) with\u00a0separate \/ boot partition\u00a0, it may fill up\u00a0after installing several updates\u00a0.\u00a0The issue occurs because older kernel versions are not automatically removed.\u00a0In this article, we'll show you how to manually uninstall older kernel versions, freeing up space in the \/ boot partition. Problem Installing new\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Aug30-Kernel-Team-Summary.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Aug30-Kernel-Team-Summary.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Aug30-Kernel-Team-Summary.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Aug30-Kernel-Team-Summary.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2017\/10\/Aug30-Kernel-Team-Summary.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/2147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/comments?post=2147"}],"version-history":[{"count":1,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/2147\/revisions"}],"predecessor-version":[{"id":2149,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/2147\/revisions\/2149"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media\/2148"}],"wp:attachment":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media?parent=2147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/categories?post=2147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/tags?post=2147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}