问题背景:单位的一台ubuntu20系统有一个每次重启电脑都要启动的脚本。我想着能不能改成每次重启自启动,在网上找了两个方法,但都没成功:
方法1:在Ubuntu下通过rc.local开机自启动脚本。按照网上的教程添加了rc.local,也修改了rc-local.service。
执行systemctl enable rc.local没问题,但是执行systemctl start rc.local和systemctl status rc.local就报错,报错图如下![](http://tiebapic.baidu.com/forum/w%3D580/sign=abfb2789e6ec08fa260013af69ef3d4d/461395cad1c8a78695efc9382109c93d71cf50cf.jpg?tbpicau=2024-09-11-05_7537daafd9401daa244719855e572629)
![](http://tiebapic.baidu.com/forum/w%3D580/sign=86299928ff389b5038ffe05ab534e5f1/9b158618367adab4fa159875cdd4b31c8601e4c8.jpg?tbpicau=2024-09-11-05_a7eb6d4fcb09c2da6e992eb5ae1dad25)
方法2:在/etc/init.d下写init脚本,然后用chkconfig命令执行开机自启动。但是chkconfig命令无法执行,百度了一下说是要先安装sysv-rc-conf![](http://tiebapic.baidu.com/forum/w%3D580/sign=4693eee87b6d55fbc5c6762e5d224f40/1c326709c93d70cf5bc3283bbedcd100baa12bd3.jpg?tbpicau=2024-09-11-05_2216b36d9782983c1f876685684ffd29)
,然后又出问题了![](http://tiebapic.baidu.com/forum/w%3D580/sign=2af3bdd724d9f2d3201124e799ec8a53/df32b13533fa828bf7191fd5bb1f4134970a5ade.jpg?tbpicau=2024-09-11-05_652ebd3994e705504d3e1beeef7813b6)
现在我已经完全束手无策了,球球大佬给个建议吧。下面是要执行的脚本文件auto_runjump.sh和init.d文件夹
![](http://tiebapic.baidu.com/forum/w%3D580/sign=54279f32729b033b2c88fcd225ce3620/316ad0160924ab181726630173fae6cd7b890be4.jpg?tbpicau=2024-09-11-05_158d6b1450eb5cd7885ba8b09aaebc7b)
![](http://tiebapic.baidu.com/forum/w%3D580/sign=8bd014ca3ad98d1076d40c39113fb807/7d1b8a82b9014a90530ec48bef773912b31beee5.jpg?tbpicau=2024-09-11-05_536f0910c6c4bf82a25bb897543a73b3)
方法1:在Ubuntu下通过rc.local开机自启动脚本。按照网上的教程添加了rc.local,也修改了rc-local.service。
执行systemctl enable rc.local没问题,但是执行systemctl start rc.local和systemctl status rc.local就报错,报错图如下
![](http://tiebapic.baidu.com/forum/w%3D580/sign=abfb2789e6ec08fa260013af69ef3d4d/461395cad1c8a78695efc9382109c93d71cf50cf.jpg?tbpicau=2024-09-11-05_7537daafd9401daa244719855e572629)
![](http://tiebapic.baidu.com/forum/w%3D580/sign=86299928ff389b5038ffe05ab534e5f1/9b158618367adab4fa159875cdd4b31c8601e4c8.jpg?tbpicau=2024-09-11-05_a7eb6d4fcb09c2da6e992eb5ae1dad25)
方法2:在/etc/init.d下写init脚本,然后用chkconfig命令执行开机自启动。但是chkconfig命令无法执行,百度了一下说是要先安装sysv-rc-conf
![](http://tiebapic.baidu.com/forum/w%3D580/sign=4693eee87b6d55fbc5c6762e5d224f40/1c326709c93d70cf5bc3283bbedcd100baa12bd3.jpg?tbpicau=2024-09-11-05_2216b36d9782983c1f876685684ffd29)
,然后又出问题了
![](http://tiebapic.baidu.com/forum/w%3D580/sign=2af3bdd724d9f2d3201124e799ec8a53/df32b13533fa828bf7191fd5bb1f4134970a5ade.jpg?tbpicau=2024-09-11-05_652ebd3994e705504d3e1beeef7813b6)
现在我已经完全束手无策了,球球大佬给个建议吧。下面是要执行的脚本文件auto_runjump.sh和init.d文件夹
![](http://tiebapic.baidu.com/forum/w%3D580/sign=54279f32729b033b2c88fcd225ce3620/316ad0160924ab181726630173fae6cd7b890be4.jpg?tbpicau=2024-09-11-05_158d6b1450eb5cd7885ba8b09aaebc7b)
![](http://tiebapic.baidu.com/forum/w%3D580/sign=8bd014ca3ad98d1076d40c39113fb807/7d1b8a82b9014a90530ec48bef773912b31beee5.jpg?tbpicau=2024-09-11-05_536f0910c6c4bf82a25bb897543a73b3)