A basic systemd file:
The file /home/andy/test must begin with:
[Unit]
Description=test
[Service]
User=andy
Type=simple
ExecStart=/home/andy/test
[Install]
WantedBy=multi-user.target
The file /home/andy/test must begin with:
#!/bin/sh -The core systemd commands: Not type systemctl not systemd
- sudo systemctl status test
- sudo systemctl restart test
- sudo systemctl stop test
- sudo systemctl daemon-reload
Taken from here:
https://stackoverflow.com/questions/37585758/how-to-redirect-output-of-systemd-service-to-a-file
Use the following properties in your systemd service unit file:
Then, assuming your distribution is using rsyslog to manage syslogs, create a file inStandardOutput=syslog StandardError=syslog SyslogIdentifier=
# without any quote
/etc/rsyslog.d/.conf
with the following content:if $programname == '' then /path/to/log/file.log
& stop
restart rsyslog (sudo systemctl restart rsyslog
)
No comments:
Post a Comment