Hi.
I've wrote a program in C for vocore2, it's working ok, now I need to make the vocore run this program after been powered on. I was reading a little and I found some posts that run scripts from the /etc/init.d/ directory but there is no any example of running an application, I mean like doing "./myapp" in the terminal.
How can I do it?
Autostart application
- chrisck87
- Posts: 3
- Joined: Fri Mar 17, 2017 10:33 pm
- Vonger
- Posts: 896
- Joined: Sun Oct 19, 2014 6:00 am
Re: Autostart application
it is linux feature, you can put the command in /etc/rc.local
- chrisck87
- Posts: 3
- Joined: Fri Mar 17, 2017 10:33 pm
Re: Autostart application
Hi! I've already solved the problem.
1 create a file in /etc/init.d directory, for example: touch /etc/init.d/autostart
2 using vi editor write this code:
#!/bin/sh /etc/rc.common
SCRIPT_NAME="myapp"
SCRIPT_PATH="/path/to/your/app"
LOG_FILE="/tmp/myapp.log"
START=150
STOP=150
start() {
echo "Starting $SCRIPT_NAME"
$SPRIPT_PATH >> $LOG_FILE 2>&1 &
}
stop() {
echo "Stopping $SCRIPT_NAME"
pids=$(pgrep myapp)
kill -9 $pids
}
3 after that you must make the scripts executables writing:
chmod +x /path/to/your/app
chmod +x /etc/init.d/autostart
4 then test the script
/etc/init.d/autostart start
5 if everything is right, stop the test
/etc/init.d/autostart stop
6 Finally enable the autorun script
/etc/init.d/autostart enable
When you restart the vocore, the program "myapp" will be executed inmediately after booting
1 create a file in /etc/init.d directory, for example: touch /etc/init.d/autostart
2 using vi editor write this code:
#!/bin/sh /etc/rc.common
SCRIPT_NAME="myapp"
SCRIPT_PATH="/path/to/your/app"
LOG_FILE="/tmp/myapp.log"
START=150
STOP=150
start() {
echo "Starting $SCRIPT_NAME"
$SPRIPT_PATH >> $LOG_FILE 2>&1 &
}
stop() {
echo "Stopping $SCRIPT_NAME"
pids=$(pgrep myapp)
kill -9 $pids
}
3 after that you must make the scripts executables writing:
chmod +x /path/to/your/app
chmod +x /etc/init.d/autostart
4 then test the script
/etc/init.d/autostart start
5 if everything is right, stop the test
/etc/init.d/autostart stop
6 Finally enable the autorun script
/etc/init.d/autostart enable
When you restart the vocore, the program "myapp" will be executed inmediately after booting
3 posts
Page 1 of 1
Who is online
Users browsing this forum: No registered users and 77 guests