If you want to make a process as a “service” and want to start that service at the time of booting of Suse Enterprise linux then you can check the following example to create your own service easily…
In this example i will create a linux service for my PROLE process and this service will be getting active automatically after the restart of the server, also if service going to crash in the background then following procedure getting up automatically.
Step 1 : Lets start with creating “prole_start” and “prole_stop” files under the installed software location like below ;
servername:/etc/systemd/system # cat /opt/tivoli/tsm/tdp_hana/prole_start
#!/bin/sh
/opt/tivoli/tsm/tdp_hana/prole -p 57323
servername:/etc/systemd/system # cat /opt/tivoli/tsm/tdp_hana/prole_stop
#!/bin/sh
/usr/bin/pkill -9 prole
Step 2 : Now we should create a file with name “prole_service” under the directory /usr/lib/systemd/system/
Here is the file content ;
servername:/etc/systemd/system # more /usr/lib/systemd/system/prole.service prole.service
::::::::::::::
/usr/lib/systemd/system/prole.service
::::::::::::::
[Unit]
Description=IBM TSM Prole Service
After=network.target
[Service]
Type=simple
ExecStart=/opt/tivoli/tsm/tdp_hana/prole_start
ExecStop=/opt/tivoli/tsm/tdp_hana/prole_stop
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
Step 3 : Next importing point is creating a “soft link” for the related “prole.service” file with following directory.
servername:/etc/systemd/system # ln -s /usr/lib/systemd/system/prole.service prole.service
Should be seen like this after the “ls -la” command ;
Step 4 : Last step is “systemctl” command with the parameter “enable” to start service automatically at boot.
servername:/etc/systemd/system # systemctl enable prole
At the and we can check the situation with YAST with following steps ;
servername:/etc/systemd/system # yast2
yast2 — system –> service manager
As you can see ; we can see the PROLE service with defined entries.
For the final step, lets kill the PROLE manually and check if service gets up automatically or not;
After 42 sn. service has started automatically (defined in the file “prole service” with the switch “RestartSec”
Thats it…