linux - 如何禁用以破折号“-”开头的服务名称
问题描述
我错误地创建了一个名为-server
. 当我尝试使用命令停止或禁用它时,sudo systemctl stop "-server"
我收到错误消息,Failed to parse signal string erver.
请注意,s
由于前面的破折号,字母消失了;我认为systemctl
由于破折号将其解释为参数。
如何以不会被误解的方式传递服务名称?
解决方案
可能最简单的解决方案是使用以下systemctl
命令将服务名称视为非参数--
:
$ systemd-run --user --unit="-myservice" /bin/sleep infinity
$ systemctl --user is-active -- -myservice.service
active
$ systemctl --user stop -- -myservice.service
$ systemctl --user is-active -- -myservice.service
inactive
推荐阅读
- drake - 我可以使用 drake 来测试 Visual SLAM 算法吗?
- amazon-web-services - AWS 经典 ELB 条件端口转发?
- python - 无法导入 pygame - ModuleNotFoundError: No module named 'pygame.base'
- python - 无论间距如何,如何从字符串中获取带有元表达式的单词
- angular - 如何处理 Firebase 错误“后端未在 10 秒内响应”
- angular - 尝试将数据注入 mat-dialog 时出错
- couchdb - 更新设计文档时,CouchDB 是否会无条件地重建索引?
- python - 正则表达式:提取 [..] 之间的字符串
- node.js - 当一组用户完成一项任务时,如何执行一项任务?这可以使用 nodejs 和 mongodb 来完成吗?
- python - alembic.util.exc.CommandError:找不到由“f1942fde9843”标识的修订版