chkconfig --list does not show newly added service - linux

I created the service script.
etc/init.d/oracle11se
The below command succeeds.
chkconfig --add oracle11se
The below command runs successfully.
/etc/init.d/oracle11se start
But the command
chkconfig --list oracle11se
does not show the newly added service. Also the service does not start on reboot.
OS release is redhat 7.2.

systemctl has replaced chkconfig.
This is the command you should use: systemctl status oracle11se.service.
If you want to list active services: systemctl list-units --type service.

Related

GitHub action self-host runner as service fails

I have installed GitHub self-hosted runner on my Ubuntu system. Getting below error when i try to configure it as service.
$ sudo ./svc.sh start
Failed to start actions.runner._services.Linux-Host01.service: Unit actions.runner._services.Linux-Host01.service is not loaded properly: Exec format error.
See system logs and 'systemctl status actions.runner._services.Linux-Host01.service' for details.
Failed: failed to start actions.runner._services.Linux-Host01.service
$ systemctl status actions.runner._services.Linux-Host01.service
● actions.runner._services.Linux-Host01.service - GitHub Actions Runner (_services.Linux-Host01)
Loaded: error (Reason: Exec format error)
Active: inactive (dead)
$ cat /etc/systemd/system/actions.runner._services.Linux-Host01.service
[Unit]
Description=GitHub Actions Runner (_services.Linux-Host01)
After=network.target
[Service]
ExecStart=/home/admin.user/actions-runner/runsvc.sh
User=admin.user
WorkingDirectory=/home/admin.user/actions-runner
KillMode=process
KillSignal=SIGTERM
TimeoutStopSec=5min
[Install]
WantedBy=multi-user.target
$ sudo journalctl -u actions.runner._services.Linux-Host01.service -f
Aug 04 08:40:47 Linux-Host01 systemd[1]: /etc/systemd/system/actions.runner._services.Linux-Host01.service:7: Invalid user/group name or numeric ID: admin.user
Additionally have provided executable permission to actions.runner._services.Linux-Host01.service but still it results same error.
What is wrong here?
I have changed User=admin.user to User=uid in the /etc/systemd/system/actions.runner._services.Linux-Host01.service file and then executed
systemctl daemon-reload
Now action service started and it is running fine.
Good morning,
First of all stop the service:
sudo ./svc.sh stop
Then make sure you have given permissions to the user:
sudo usermod -a -G <USER>
Now try to start the service:
sudo ./svc.sh start
And tell me if this works when check the status.
If not works please do the same but sudo permissions:
sudo su
And then try again all without sudo command because you are actually on root.
Have a great day!
This simply means you've not installed the runner
sudo ./svc.sh install // install the runner
sudo ./svc.sh start // then start it
Remember, this is the best way to go about it than using the ./run.sh script, as the runner will always be running in the background.
Use sudo ./svc.sh status to confirm that the runner is up and running.

Failed to start couchbase-server.service: Unit couchbase-server.service is masked

couchbase service stopped , so i started it manually by exec following command:
sudo service couchbase-server start and got response
Failed to start couchbase-server.service: Unit couchbase-server.service is masked.
I have ubuntu 16.04LTS and couchbase 5.1
you can unmask your service
sudo systemctl unmask couchbase-server
sudo systemctl start couchbase-server
Go to $CouchbaseHome and run following command to start and stop manually
Start
 ./bin/couchbase-server \-- -noinput -detached
Shutdown
./bin/couchbase-server -k

Stopping postgresql from starting on ubuntu startup

Ubuntu 16.04.1 LTS
I have tried:
sudo update-rc.d -f postgresql remove
and
sudo vim /etc/postgresql/9.5/main/start.conf
then i change the word "auto" to "disabled"
Then i reboot the computer, and when it starts, i login and do:
sudo service --status-all | grep postgresql
Which returns:
[ + ] postgresql
So it is still starting when the server starts.
What is left for me to do? I don't want this service running when the computer starts, only when i manually start it with:
sudo service postgresql start
Use systemctl command to manage postgresql service:
stop service:
systemctl stop postgresql
start service:
systemctl start postgresql
show status of service:
systemctl status postgresql
disable service(not auto-start any more)
systemctl disable postgresql
enable service postgresql(auto-start)
systemctl enable postgresql
Ok. it's fixed thanks to Koen De Groote.
I did:
echo manual | sudo tee /etc/init/postgresql.override
and
sudo systemctl disable postgresql.service
and
sudo systemctl disable postgresql
....I don't know which one of them did it, but its not starting any more... Thank you...

How do I start a service on boot in debian?

So I created a service and made it executale in /etc/init.d
Then I tried to make it start after boot with the following command:
update-rc.d <myService> defaults
But the output were warnings of other services (which work just fine by the way) and I don't want to touch those.
My next attempt to solve this was to add the following lines in the rc.local file:
do_start() {
service <someOtherService> stop
service <myService> stop
sleep 5
service <someOtherService> start
service <myService> stop
........
As I said, I have some other service that works just fine, but my service which I am currently trying to add wont start after boot.
One more thing that I would like to add is when I manually enter:
service <myService> start/stop
then it works just fine
To add a service at boot, you can add an Upstart job.
Create your conf file in /etc/init (e.g. /etc/init/myjob.conf)
with a content like this (Example)
description "My job"
start on startup
task
exec /path/to/script.sh
More informations here (Debian doc)
Info: you need the upstart package.
The following works very well for me.
First determine if your system is running SysV init or systemd, for that use:
$ ps -p 1
If SysV init:
$ sudo update-rc.d <service_name> defaults 95 10
If systemd:
$ sudo /bin/systemctl daemon-reload
$ sudo /bin/systemctl enable <service_name>.service
I successfully used the last one on a ParrotSecurity OS that is based on Debian 5.

Can I control a user systemd using 'systemctl --user' after sudo su - myuser?

I have a service that I want to start with system startup. I have built a ap#.service definition for it as a template, because there could be many instances.
Defined in the root systemd, this works well, and starts and stops the service with the system. The service instance is installed with systemctl enable ap#inst1 as would be expected. Root is also able to start and stop the service without problems. The service runs in its own account (myuser), not root, controlled by User=myuser in the ap#.service template.
But I want user 'myuser' to be able to start and stop their own service, without compromising system security.
I switched to using a user systemd, and enabled lingering with loginctl enable-linger myuser. I then enable the service defined in the ~myuser/.config/systemd/user directory. The service now starts and stops cleanly with the system, as designed. If I log in to a terminal as 'myuser', systemctl --user start ap#inst1, and systemctl --user stop ap#inst1 both work perfectly.
However, if I log in as a different user (user2) and perform sudo su - myuser in a terminal, then systemctl --user commands now fail with error message "Failed to get D-Bus connection: no such file or directory".
How do I enable systemctl --user to work after a sudo su - myuser command to switch the user?
I found the answer on another site with further searches using different terms.
The solutions needed was to provide the shell with information to reach the correct DBUS for the user.
By adding the following environment variables to the shell before running systemctl --user, the DBUS problem is eliminated, and systemctl operates correctly.
export XDG_RUNTIME_DIR="/run/user/$UID"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
To ensure that the DBUS_SESSION_BUS_ADDRESS is available in the sudo shell, I added the environment variables to ~/.bash_profile of the target userid. This requires that a login shell ( sudo su - myuser or sudo -l myuser) is created in order to create the correct environment.
Alternatively, add the creation of the environment variables to ~/.bashrc (or equivalent for other shells). The environment will then be established anew for all shell creations.
systemd 248 (released March 2021) introduced support for the syntax -M myuser# for specifying another user.
$ sudo systemctl --user -M myuser# start ap#inst1
A side-note:
If you want to get an interactive login shell for the user myuser
$ sudo machinectl shell myuser#

Resources