我有一个 shell 脚本,用于监控 auth 日志以在新的系统登录时发出警报,当我手动启动它时,它可以正常工作,但是当我尝试使用 systemd 服务将其作为服务加载时,它无法加载。我尝试了脚本中的无数变体,但我不知道如何定位问题...
journalctl -xe 给我以下无用的错误信息...
-- Subject: Unit quackme.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit quackme.service has begun starting up.
Dec 09 11:27:34 dc1 systemd[1]: quackme.service: Control process exited, code=exited status=5
Dec 09 11:27:34 dc1 systemd[1]: Failed to start quackme.
-- Subject: Unit quackme.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit quackme.service has failed.
--
-- The result is failed.
该服务定义如下...
[Unit]
Description=quackme
[Service]
Type=forking
ExecStart=/home/myuser/quack/quackmeservicescript.sh
[Install]
WantedBy=multi-user.target
我不确定 shell 脚本所说的内容是否重要,但它在这里......
#!/bin/sh
/usr/bin/tail -fn0 /var/log/auth.log | awk '/New session/ { system("wget http://example.com/fut/9bgfej8s755sktgh0o3irgag0/alert.jsp") }'