linux - Auto-Running a C Program on Raspberry PI -


how can make c code auto-run on raspberry pi? have seen tutorial achieve not know still missing. initialization script shown follows:

#! /bin/sh # /etc/init.d/my_settings # # run can written here ### begin init info # provides:     my_settings # required-start:   $remote_fs $syslog # required-stop:    $remote_fs $syslog # default-start:    2 3 4 5  # default-stop: 0 1 6 # x-interactive:    true # short-description:    script start c program @ boot time # description:      enable service provided my_settings ### end init info  # carry out different functions when asked system case "$1" in  start) echo "starting rpi data collector program" # run application want start sudo /home/pi/documents/c_projects/cfor_rpi/charlie & ;; stop) echo "killing rpi data collector program" # kills application want stop sudo killall charlie ;; *) echo "usage: /etc/init.d/my_settings {start | stop}" exit 1   ;; esac exit 0 

the problem program not run @ boot time , not know why. missing? "killall" statement "killing" useful process during execution time? making code run background application know after few seconds, when rpi initializing, asks username , password in order initialize session. possible rpi not executing code because not providing logging information? not have monitor program has run once plug rpi in. lot in advance!!

how scripts/services run @ startuptime, depends on type of init system used. off top of head, i'd distginguish following 4 types:

  • embedded style: single shell script has commands start system. script @ 1 off paths kernel tries start init process.
  • bsd style
  • system v style: uses /etc/inittab , latr scripts in /etc/rc*.d/ start services 1 one
  • systemd

raspbian dervices debian, suppose system v style. have symlink script /etc/rc2.d like

ln -s /etc/init.d/your-script /etc/rc2.d/s08my-script 

not structure of link name: says, should started when run level entered, , '08' determines position (do ls /etc/rc2.d/ see other links).

more details: init(8).

update-rc.d(8) proper wway create symlinks on debian. see manpage:

update-rc.d - install , remove system-v style init script links 

i advice read @ least man pages update-rc.d(8) , init(8).


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -