用户重新启动后自动启动不起作用 [英] Autostart does not work after user reboot

查看:93
本文介绍了用户重新启动后自动启动不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在重启后自动启动一个 sh 脚本.

I want to autostart a sh script after reboot.

我将以下行添加到 /etc/xdg/lxsession/LXDE-pi/autostart.

@/home/pi/mog/run.sh

如果我将 raspberrypi-2 插入电源线或在停止后打开它,一切正常.但是,当我运行 shell 命令时sudo shutdown -r now 重启后自动启动方法不起作用?

Everything works fine if i plug the raspberrypi-2 to power line or switch on it after halt. However when i run shell command sudo shutdown -r now the autostart method does not work after reboot?

我想在重启后运行一个 C++ 应用程序,我的 run.sh 脚本在下面.

I want to run a C++ application after reboot and my run.sh script is below.

<代码>#!/bin/bash睡 5/home/pi/mog/mog -platform xcb

推荐答案

我想这取决于您尝试运行的 shell 脚本类型.

I guess it depends on what type of shell script you are trying to run.

看起来有几种方法可以做到:

Looks like there are several ways to do it:

1.从控制台开始

为您的启动脚本创建一个文件并将您的脚本写入该文件:

Create a file for your startup script and write your script in the file:

 $ sudo nano /etc/init.d/superscript
 Save and exit: Ctrl+X, Y, Enter

使脚本可执行:

 $ sudo chmod 755 /etc/init.d/superscript

注册要在启动时运行的脚本:

Register script to be run at startup:

 $ sudo update-rc.d superscript defaults

2.从登录开始

确保您在 pi 文件夹中:

Make sure you are in the pi folder:

 $ cd ~

创建文件并编写脚本在文件中运行:

Create a file and write a script to run in the file:

 $ sudo nano superscript

在这里粘贴sh脚本的内容

Paste contents of sh script here

 Save and exit: Ctrl+X, Y, Enter

打开 .bashrc 进行配置:

Open up .bashrc for configuration:

 $ sudo nano .bashrc

向下滚动到底部并添加以下行:./superscript

Scroll down to the bottom and add the line: ./superscript

 Save and exit: Ctrl+X, Y, Enter

3.从桌面环境开始

(您的方法听起来似乎不适合您的需求)

(Your method which sounds like its not working for your needs)

这篇关于用户重新启动后自动启动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆