Not able to start service with systemd config
by james000 from LinuxQuestions.org on (#6PD98)
Hi,
I have Centos 8. There is one service, which I want to be restricted with only 2 CPU core and 8GB of memory as requirement. As cgroup is deprecated, I am trying to set it up with systemd config. But I am not able to start it, though status says "success". If I run it manually it starts well. Can someone help me to figure, what else I am missing here ?
Below is example of starting service manually vs with system
Code:[root@centos-8-prod ~]# su - webadm4
Last login: Mon Jul 22 10:14:55 PDT 2024 on pts/0
[webadm4@centos-8-prod ~]$ /export/home/webadm4/snapshotreports-4.0/snapshotreports.sh stop
Instance Name snapshotreports-4.0
Stopping snapshotreports-snapshotreports-4.0 pid 134572
[webadm4@centos-8-prod ~]$
[webadm4@centos-8-prod ~]$ exit
logout
[root@centos-8-prod ~]# ps -ef | grep snapshot
root 134659 134401 0 10:15 pts/0 00:00:00 grep --color=auto snapshot
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# cat /etc/systemd/system/system.slice.d/controllers.conf
[Slice]
CPUAccounting=yes
MemoryAccounting=yes
TasksAccounting=yes
[root@centos-8-prod ~]# cat /etc/systemd/system/snapshot_report.service
[Unit]
Description=Snapshot report
[Service]
User=webadm4
Group=webadm4
ExecStart=/export/home/webadm4/snapshotreports-4.0/snapshotreports.sh start
CPUAffinity=0,1
MemoryMax=8G
Type=exec
[Install]
WantedBy=multi-user.target
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# systemctl status snapshot_report.service
snapshot_report.service - Snapshot report
Loaded: loaded (/etc/systemd/system/snapshot_report.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2024-07-19 13:51:53 PDT; 2 days ago
Process: 1343 ExecStart=/export/home/webadm4/snapshotreports-4.0/snapshotreports.sh start (code=exited, status=0/SUCCESS)
Main PID: 1343 (code=exited, status=0/SUCCESS)
Jul 19 13:51:48 centos-8-prod systemd[1]: Starting Snapshot report...
Jul 19 13:51:50 centos-8-prod snapshotreports.sh[1343]: Instance Name snapshotreports-4.0
Jul 19 13:51:51 centos-8-prod snapshotreports.sh[1343]: Starting snapshotreports-4.0 ... see /export/home/webadm4/snapshotreports-4.0/logs/snapshotreports.log for messages
Jul 19 13:51:53 centos-8-prod systemd[1]: snapshot_report.service: Succeeded.
Jul 19 13:51:53 centos-8-prod systemd[1]: Started Snapshot report.
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# systemctl start snapshot_report.service
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# systemctl status snapshot_report.service
snapshot_report.service - Snapshot report
Loaded: loaded (/etc/systemd/system/snapshot_report.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2024-07-22 10:16:10 PDT; 3s ago
Process: 134674 ExecStart=/export/home/webadm4/snapshotreports-4.0/snapshotreports.sh start (code=exited, status=0/SUCCESS)
Main PID: 134674 (code=exited, status=0/SUCCESS)
Jul 22 10:16:10 centos-8-prod systemd[1]: Starting Snapshot report...
Jul 22 10:16:10 centos-8-prod systemd[1]: Started Snapshot report.
Jul 22 10:16:10 centos-8-prod snapshotreports.sh[134674]: Instance Name snapshotreports-4.0
Jul 22 10:16:10 centos-8-prod snapshotreports.sh[134674]: Starting snapshotreports-4.0 ... see /export/home/webadm4/snapshotreports-4.0/logs/snapshotreports.log for messages
Jul 22 10:16:10 centos-8-prod systemd[1]: snapshot_report.service: Succeeded.
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# ps -ef | grep snapshot
root 134688 134401 0 10:16 pts/0 00:00:00 grep --color=auto snapshot
[root@centos-8-prod ~]#/export/home/webadm4/snapshotreports-4.0/logs/snapshotreports.log is the log file. If I start service manually, it would see the updates, but nothing with systemd
Thanks
I have Centos 8. There is one service, which I want to be restricted with only 2 CPU core and 8GB of memory as requirement. As cgroup is deprecated, I am trying to set it up with systemd config. But I am not able to start it, though status says "success". If I run it manually it starts well. Can someone help me to figure, what else I am missing here ?
Below is example of starting service manually vs with system
Code:[root@centos-8-prod ~]# su - webadm4
Last login: Mon Jul 22 10:14:55 PDT 2024 on pts/0
[webadm4@centos-8-prod ~]$ /export/home/webadm4/snapshotreports-4.0/snapshotreports.sh stop
Instance Name snapshotreports-4.0
Stopping snapshotreports-snapshotreports-4.0 pid 134572
[webadm4@centos-8-prod ~]$
[webadm4@centos-8-prod ~]$ exit
logout
[root@centos-8-prod ~]# ps -ef | grep snapshot
root 134659 134401 0 10:15 pts/0 00:00:00 grep --color=auto snapshot
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# cat /etc/systemd/system/system.slice.d/controllers.conf
[Slice]
CPUAccounting=yes
MemoryAccounting=yes
TasksAccounting=yes
[root@centos-8-prod ~]# cat /etc/systemd/system/snapshot_report.service
[Unit]
Description=Snapshot report
[Service]
User=webadm4
Group=webadm4
ExecStart=/export/home/webadm4/snapshotreports-4.0/snapshotreports.sh start
CPUAffinity=0,1
MemoryMax=8G
Type=exec
[Install]
WantedBy=multi-user.target
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# systemctl status snapshot_report.service
snapshot_report.service - Snapshot report
Loaded: loaded (/etc/systemd/system/snapshot_report.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2024-07-19 13:51:53 PDT; 2 days ago
Process: 1343 ExecStart=/export/home/webadm4/snapshotreports-4.0/snapshotreports.sh start (code=exited, status=0/SUCCESS)
Main PID: 1343 (code=exited, status=0/SUCCESS)
Jul 19 13:51:48 centos-8-prod systemd[1]: Starting Snapshot report...
Jul 19 13:51:50 centos-8-prod snapshotreports.sh[1343]: Instance Name snapshotreports-4.0
Jul 19 13:51:51 centos-8-prod snapshotreports.sh[1343]: Starting snapshotreports-4.0 ... see /export/home/webadm4/snapshotreports-4.0/logs/snapshotreports.log for messages
Jul 19 13:51:53 centos-8-prod systemd[1]: snapshot_report.service: Succeeded.
Jul 19 13:51:53 centos-8-prod systemd[1]: Started Snapshot report.
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# systemctl start snapshot_report.service
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# systemctl status snapshot_report.service
snapshot_report.service - Snapshot report
Loaded: loaded (/etc/systemd/system/snapshot_report.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2024-07-22 10:16:10 PDT; 3s ago
Process: 134674 ExecStart=/export/home/webadm4/snapshotreports-4.0/snapshotreports.sh start (code=exited, status=0/SUCCESS)
Main PID: 134674 (code=exited, status=0/SUCCESS)
Jul 22 10:16:10 centos-8-prod systemd[1]: Starting Snapshot report...
Jul 22 10:16:10 centos-8-prod systemd[1]: Started Snapshot report.
Jul 22 10:16:10 centos-8-prod snapshotreports.sh[134674]: Instance Name snapshotreports-4.0
Jul 22 10:16:10 centos-8-prod snapshotreports.sh[134674]: Starting snapshotreports-4.0 ... see /export/home/webadm4/snapshotreports-4.0/logs/snapshotreports.log for messages
Jul 22 10:16:10 centos-8-prod systemd[1]: snapshot_report.service: Succeeded.
[root@centos-8-prod ~]#
[root@centos-8-prod ~]# ps -ef | grep snapshot
root 134688 134401 0 10:16 pts/0 00:00:00 grep --color=auto snapshot
[root@centos-8-prod ~]#/export/home/webadm4/snapshotreports-4.0/logs/snapshotreports.log is the log file. If I start service manually, it would see the updates, but nothing with systemd
Thanks