我正在编写一个 bash 脚本来执行每日备份。这个脚本最终会在每天早上(cron 或 systemd)自动运行。
我想完成的是
我创建的 bash 脚本如下所示:
# Stop myservice
systemctl stop myservice.service
# Do all the backing up here...
# Start myservice
systemctl start myservice.service
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我运行这个脚本时,它在 systemctl stop/start 调用期间需要我的密码。如果这是自动运行,显然它不能每次都需要密码。如何在不需要此密码的情况下自动运行此脚本?
Ubuntu 18.04
谢谢!