在GNU/Linux上,启动时运行的脚本应该写入/etc/rc.local!

1 min

language: ja bn en es hi pt ru zh-cn zh-tw

大家好,我是无能。

出乎意料的是,有很多文章提到写入.profile等文件,但由于这些操作是在登录后执行的,对于运行服务器的系统来说,反而可能不怎么使用。

后期添加并需要常驻运行的脚本或启动项往往会越来越多,常常让人分不清哪个是哪个,因此我选择将它们写入rc.local。


sudo vi /etc/rc.local

~

#!/bin/sh
tlp start  
# /etc/rc.local – rc.local for Artix Linux

# Enter your custom commands here.

~

红色字体是本次添加的部分。
如果命令很多,最好将它们汇总到一个名为startup.sh的shell脚本中执行。

sudo chmod +x /etc/rc.local

这样就可以了。

结束。

Related Posts