Could you post a sample scripts on how to run a .net core program on startup? or could you provide the step by step procedure? I was able to run a .net core program on it by installing the .net runtime but what I need now is to run the program every bootup or startup of the PLC automatically. I have tried some solutions in google but nothing work like: - Creating sh file in /etc/init.d/ or /etc/rc5.d. -Creating cronjob My sh file contain: #!/bin/bash cd /opt/plcnext/pondus-services/PondusBaseStationV2/ dotnet PondusBaseStation.dll but nothing works for me.
Hello,
If you want to create Init.d scripts there is a lot you have to keep in mind.
This is about general linux or Init.d services so I suggest you look up a “update.rc” or “Init.d” Tutorial on the web.
I guess your script right now will block the rest of your boot up sequence as you do not spawn a seperate process for your dotnet executable.At the very least add a “&” after your “dotnet some.dll &” comand.
Small example how such a script could look with start-stop-daemon ... ```bash #! /bin/sh ### BEGIN INIT INFO # Provides: socat # Required-Start: $local_fs $time $network # Required-Stop: $local_fs $time $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Daemon to setup Socat connection to GWd # # Description: The Socat init script will start/stop Socat as specified in /etc/default/socat/socat.conf # Logs can be found at /var/log/socat.log ### END INIT INFO NAME=socat DAEMON=/usr/bin/socat ## /usr/bin/dotnet some.dll SOCAT_DEFAULTS='-d -d -d -lf /var/log/socat.log'# Some parameters how to run your dll maybe debug? where to store logs? . /etc/default/socat/socat.conf # load some args to run with your dll PATH=/bin:/usr/bin:/sbin:/usr/sbin [ -x $DAEMON ] || exit 0 start_socat() { start-stop-daemon --oknodo --quiet --start \\ --pidfile /var/run/socat.pid \\ --background --make-pidfile \\ --exec $DAEMON -- $SOCAT_DEFAULTS $OPTIONS < /dev/null do_wait_tty chown admin:plcnext_firmware $TTYNAME init_tty }
Hi Oliver, Thanks for the reply. I have added & on the end if my script and create it on **/etc/init.d/
**
program runs ok when I execute this : /etc/init.d/pbss start
but still it doesn’t execute in startup.
Hey,
try
“dotnet some.dll &> /var/log/dotnetPbss.log &”
Then you will at least know whats going on with the dotnet.
You can also add additional echos to your script to see where it might fail.
And have a look at “/var/log/*” for details what is going on at your system startup.Did you execute
“update-rc.d [-n] [-r ] [-s] start|stop NN runlvl [runlvl] […] . update-rc.d [-n] [-r ] [-s] start|stop NN runlvl [runlvl] […] .” to register the init.d script?kind regards,
Oliver
Hi Oliver, Thanks, It works now. The key is the logging you have taught, I was able to see why my program is not running. There are also some configs that I adjust on my program for it to work but now I can confirm that it was executing on startup. Many Thanks!