在bash配置文件(通常是.bashrc
或.bash_profile
等)中定义一个名为reloadctl的函数:
最终实际执行的是(全局生效):
vi /etc/profile
1 reloadctl() { 2 if [ "$#" -ne 2 ]; then 3 echo "Usage: hehe -n <service_name>" 4 return 1 5 fi 6 7 if [ "$1" != "-n" ]; then 8 echo "Usage: hehe -n <service_name>" 9 return 1 10 fi 11 12 service_name="$2" 13 14 systemctl daemon-reload 15 systemctl start "$service_name.service" 16 systemctl enable "$service_name.service" 17 systemctl status "$service_name.service" 18 }
然后source 一下生效;
接下来就可以调用:
reloadctl -n digg.api
实际执行的就是:
systemctl daemon-reload
systemctl start digg.api.service
systemctl enable digg.api.service
systemctl status digg.api.service
标签:name,service,api,自定义,systemctl,reloadctl,digg,后续,方便使用 From: https://www.cnblogs.com/wenzd/p/17894950.html