shell脚本设定开机自启动

1.系统级

cd /etc/systemd/system
sudo vim xxx.service
[Unit]
Description = blablablabla

[Service]
Type = simple
ExecStart = /bin/bash /脚本路径/demo.sh
Restart = always
[Install]
WantedBy = multi-user.target

启动服务

systemctl enable xxx.service #开机自启动
systemctl start xxx.service #单次启动
systemctl stop xxx.service #停止
systemctl status xxx.service #查看状态

添加或修改配置文件后,需要重新加载

systemctl daemon-reload

2.用户级

系统级会在root下运行。但我需要访问用户路径,在root权限在没有找到获得用户路径的方法,所以采用了用户级。

cd /etc/systemd/user
sudo vim xxx.service
[Unit]
Description = /opt/RA/screenrecording/videostart.sh when the computer starts up

[Service]
Type = simple
ExecStart = /bin/bash /opt/RA/screenrecording/videostart.sh
Restart = always
[Install]
WantedBy = default.target
systemctl --user enable xxx.service #开机自启动
systemctl --user start xxx.service #单次启动
systemctl --user stop xxx.service #停止
systemctl --user status xxx.service #查看状态
systemctl --user daemon-reload
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇