How do I instruct rPi B+ to run java application at boot time in ArchLinux, I mean, where do I add java -jar octopus.jar
to execute at boot time?
Find a good overview as how to autostart scripts or services at the Archlinux Wiki. A convenient way for simple testing is the use of cron. Edit crontab by crontab -e
and use the alias @reboot
to schedule a task to be started after reboot. Use full paths for you executables though.
Another typical way is to utilize the systemd
default init framework that allows services to be enabled using the systemctl
command.
I solved the problem by using this tutorial.
To summarize it, here are the necessary steps:
- Create the file for startup service:
vi /etc/systemd/system/myservice.service
- Fill the created file with the information needed to run AND install your service:
[Unit] Description=myservice custom script [Install] WantedBy=multi-user.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/path_to_custom_scripts/myservice_startup_script.sh
- Save the file
- Edit and save the script file
/path_to_custom_scripts/myservice_startup_script.sh
- Install the service:
systemctl enable myservice.service
- Check state of the service:
systemctl is-enabled myservcice.service
If the service is running, then the service script has been edited without errors and voila, that's it!
-
2Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Steve Robillard Sep 23 '14 at 8:52
-
1You can edit your own answer to include what you learned, how you used it and what seemed important to you. The answer will be improved and the people that downvoted might revoke that vote too. – Ghanima♦ Sep 23 '14 at 9:08
-
First it is not my opinion, but rather a standard set for all of the stackexxchange sites. The rational behind it is to avoid link rot, and keep answers useful despite what may happen to the linked resource. Each down vote counts as -1 so if you see a big drop it is not one person's opinion, but rather the community. If you do as @Ghanima suggested and improve the answer I will remove my down vote - simply add a comment with an @ before my username and I will see it. – Steve Robillard Sep 23 '14 at 9:18
-
1@MarkoFrelih On behalf of the community, thank you for sharing your experience :-) I'm sure that will help other people. – Morgan Courbet Oct 3 '14 at 11:51