Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

How to run an executable file after boot up immediately?

Discussion in 'Command Line' started by vikranth, Jul 21, 2017.

Tags:
  1. vikranth

    vikranth New Member

    Joined:
    Jul 21, 2017
    Messages:
    1
    Likes Received:
    0
    I have one a.out executable file, now I need to run this file immediately boot up my orange pi. I am using Debian 8.


     
  2. Rob

    Rob Administrator
    Staff Member

    Joined:
    Oct 27, 2011
    Messages:
    269
    Likes Received:
    744
    Hey there - welcome to the forum!

    There are multiple ways to do this. Regardless of which distribution you run, you can use cron to accomplish running scripts or commands etc.. on boot with a cron entry similar to this:

    Code:
    @reboot /path/to/script
    I use this on one of my servers running CentOS and it works regardless of if i'm rebooting the machine or booting from being shut down. I have heard/read that it may not run from a cold boot but not sure if that's going to be a distribution thing or what.

    Give that a shot and let us know if it gets you going.

    I'm sure others will come along and post other options for you as well.
     
    wizardfromoz, vikranth and atanere like this.
  3. Thsnos023

    Thsnos023 New Member

    Joined:
    Dec 17, 2017
    Messages:
    1
    Likes Received:
    1
    Add your script to the /etc/init.d/ directory and enable it

    sudo update-rc.d <script> defaults
    sudo update-rc.d <script> enable

    Make sure that root is the script owner
     
    wizardfromoz likes this.
  4. EchelonX

    EchelonX New Member

    Joined:
    Mar 21, 2018
    Messages:
    2
    Likes Received:
    0
    Use the kernel command line parameter: "init=[absolute_path_to_you_executable]/a.out"

    Hahaha. I'm just kidding. I highly doubt that's what you are looking for. I recommend Rob's solution. Use Cronie and apply the crontab entry to the user you want your executable to run as. Ensure that cronie is set to run at boot. This will depend on your init system, but almost all distros these days use systemd. With systemd, as the root user, run "systemctl enable cronie" . As the user you want to execute a.out as, run "crontab -e" . From there you can enter the configuration provided by Rob. If it opens with a text editor you don't like, you can use something like "EDITOR=/bin/nano crontab -e". If you need more granular control over the run sequence of a.out during boot, you'll need to look into setting it up as a systemd service instead. I've never done that so I can't help you with the details there.
     

Share This Page