dimanche 8 mars 2015

Running a script during booting/startup; init.d vs cron @reboot


I am currently trying to understand the difference between init.d and cron @reboot for running a script at startup/booting of the system.


The use of @reboot (this method was mentioned in this forum by hs.chandra) is some what simpler, by simply going into crontab -e and creating a @reboot /some_directory/to_your/script/your_script.txt and then your_script.txt shall be executed every time the system is rebooted. An in depth explanation of @reboot is here


Alternatively by embedding /etc/init.d/your_script.txt into the second line of your script ie:



#!/bin/bash
# /etc/init.d/your_script.txt


You can run chmod +x /etc/init.d/your_script.txt and that should also result for your_script.txt to run every time the system is booted.


Q1: What is the key differences between the two?

Q2: Which is more robust?

Q3: Is there a better one out of the two?

Q4: Is this the correct way of embedding a script to run during booting?


I will be incorporating a bash .txt file to run during startup.



Aucun commentaire:

Enregistrer un commentaire