How to run executable after bootup automatically in linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to run executable after bootup automatically in linux

6,446 Views
chandraevolute
Contributor V

I am using poky build toolchain for imx6ulevk board. Using kernel version 3.14.38 and poky version 1.8. I am able to run the application manually after bootup with command ./Executable. But the application needs to be ran after bootup automatically. Is there any way to do it.

Labels (2)
0 Kudos
5 Replies

2,824 Views
b36401
NXP Employee
NXP Employee

You need to add the application into some startup script like /etc/rc.local.

However you need to make sure that all required services of the system are already running at the time the application starts.

Have a great day,

Victor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

2,824 Views
danwei_luo
NXP Employee
NXP Employee

Hi chandra,

Sure! The simplest way to do that is to add this command in /etc/rc.local script, so that it will be executed automatically during startup.

For example, you can add:

cd /usr/bin (where you put your application file)

./your_application

If you want it running in background, you can use ./your_application &

Best regards,

Danwei Luo

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

2,824 Views
chandraevolute
Contributor V

Hi when I am trying to run the application in background after rebooting the application is running twice what may be the issue??

0 Kudos

2,824 Views
chandraevolute
Contributor V

How can I put the application in /usr/bin as i develop application outside the build. I want it to be a part of my image build. So when I do bitbake core-image-base my application should compile generate executable and sit in /usr/bin and  I will write the start up script as you suggested. Do i need to add a layer for that??

I need one more help also where to get the set_image_autologin() function??

0 Kudos

2,824 Views
danwei_luo
NXP Employee
NXP Employee

Hi Chandra,

Sorry for the delay!

If you are just testing your application on the board, then actually there are a lot of methods to put your application to /usr/bin. For example, if you are using SD card as file system, then you can cp the application to /usr/bin. If you are using eMMC, then maybe you can try scp, or unpack rootfs.tar.gz, cp your application to /usr/bin, repack it to rootfs.tar.gz, and then use mfgtools to download it to eMMC.

But if you are providing your application to your customers, then the answer is yes. To create a new layer in Yocto, you can refer to Yocto Project Development Manual

For auto-login function, you can refer to Reg: Auto-Login and run a script Automatically

Best regards,

Danwei Luo

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------