首页 > 其他分享 >Auto run after booting up OS

Auto run after booting up OS

时间:2024-07-15 09:40:40浏览次数:6  
标签:run service script Auto after etc myscript file your

To execute a script automatically after booting up to Ubuntu OS, you can place the script in the /etc/rc.local file or create a systemd service. Here's how to do it using both methods:

Method 1: Using /etc/rc.local

  1. Open the /etc/rc.local file with root privileges using a text editor like nano:
sudo nano /etc/rc.local
  1. Add your script at the end of the file, ensuring that it has execute permissions (if not already set). For example, if your script is located at /home/user/myscript.sh, add the following line:
/bin/bash /home/user/myscript.sh
  1. Save and close the file.

  2. Make sure /etc/rc.local has execute permissions:

sudo chmod +x /etc/rc.local
  1. Reboot your system to test the script execution.

Method 2: Using systemd service

  1. Create a new systemd service file:
sudo nano /etc/systemd/system/myscript.service
  1. Add the following content to the file, replacing /path/to/your/script.sh with the actual path to your script:
[Unit]
Description=My Script Service
After=network.target

[Service]
ExecStart=/bin/bash /path/to/your/script.sh
Restart=on-failure
User=root
Group=root
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=myscript

[Install]
WantedBy=multi-user.target
  1. Save and close the file.

  2. Enable and start the service:

sudo systemctl enable myscript.service
sudo systemctl start myscript.service
  1. Check the status of the service:
sudo systemctl status myscript.service
  1. Reboot your system to test the script execution. The script will be executed automatically after booting up.

标签:run,service,script,Auto,after,etc,myscript,file,your
From: https://www.cnblogs.com/fredqq/p/18302496

相关文章

  • Kotlin标准函数(语法糖)let with run also apply快速讲解
    目录1、知识储备——扩展函数原理定义扩展函数调用扩展函数2、返回值为上下文对象的标准函数applyalso3、返回值为Lambda表达式结果letrunwith4、一表总结1、知识储备——扩展函数原理Kotlin在不继承父类或实现接口下,也能扩展一个类的新功能定义扩展函数f......
  • auto关键字
    作用:能自动推断出是什么数据类型代码示例:autoname()//能判断出返回值时字符串类returnstd::string("hhh");弊端:对变量类型不明确,可能会破坏依赖特定类型的代码比如字符串类的.strlen()什么时候用:当类型过长时intmain(){std::vector<std::string>strings;strin......
  • C#面:Application builder的use和run方法有什么区别?
    这两个⽅法都在startupclass的configure⽅法⾥⾯调⽤。都是⽤来向应⽤请求管道⾥⾯添加中间件的。Use⽅法可以调⽤下⼀个中间件的添加,⽽run不会。在C#中,Applicationbuilder是用于构建和配置应用程序的类。它提供了一些方法来设置应用程序的各种属性和行为。其中,use和run方......
  • Python+wxauto=微信自动化?
    Python+wxauto=微信自动化?一、wxauto库简介1.什么是wxauto库        wxauto是一个基于UIAutomation的开源Python微信自动化库。它旨在帮助用户通过编写Python脚本,轻松实现对微信客户端的自动化操作,从而提升效率并满足个性化需求。这一工具的出现,为经常需要在电脑......
  • Windows11系统System.Runtime.Serialization.dll文件丢失问题
    其实很多用户玩单机游戏或者安装软件的时候就出现过这种问题,如果是新手第一时间会认为是软件或游戏出错了,其实并不是这样,其主要原因就是你电脑系统的该dll文件丢失了或没有安装一些系统软件平台所需要的动态链接库,这时你可以下载这个System.Runtime.Serialization.dll文件(挑选......
  • Crunchy Bridge 通过duckdb 对于pg 进行扩展
    Crunchy最近发布了一个CrunchyBridge的服务,通过duckdb扩展了pg对于数据分析的能力,官方发布的内容值得学习下参考玩法说明实际上目前社区也有一个pg的duckdb_fdw,也值得体验下,CrunchyBridge不是一个fdw扩展,反而是使用了类似citus的postgreshooks参考资料https://g......
  • Llama2大语言模型在云GPU(AutoDL)上进行训练微调(自定义数据集)
    Llama2是Meta开源的语言大模型,它经过训练的数据集包含2万亿个token。相比Llama,Llama2的上下文长度已经从2048扩展到4096,这使其能够理解和生成更长的文本。Llama2包括了多个模型,分别是7B、13B和70B的模型。一、准备工作在autodl平台租用实例(直接搜索,有许多租用教程,建议租......
  • AutoKG:为语言模型打造高效自动化知识图谱
    在人工智能领域,大型语言模型(LLMs)如BERT、RoBERTa、T5和PaLM等,以其在自然语言处理(NLP)任务中的卓越性能而著称。然而,这些模型在提供信息时可能会产生“幻觉”,即提供看似合理但与事实不符的预测。同时它们的“黑箱”特性也影响了模型的可解释性和准确性。为了解决这些问题,研究者们......
  • SMPLify论文阅读:Keep it SMPL: Automatic Estimation of 3D Human Pose and Shape fro
    基本信息时间:2016会议/期刊:ECCV论文网址:https://arxiv.org/pdf/1607.08128一作单位:MaxPlanckInstituteforIntelligentSystems文章内容关键词:3D身体形状,人体姿态,卷积神经网络文章类型:算法/基于优化的方法硬件/算法类型:SMPL/HMR核心思想:从单张图......
  • unplugin-auto-import 简介
    unplugin-auto-import简介unplugin-auto-import是一个用于自动导入常用函数和变量的Vite和Webpack插件。它可以帮助开发者减少手动导入的麻烦,提高开发效率。安装使用npm或yarn安装:npminstall-Dunplugin-auto-import或yarnadd-Dunplugin-auto-import配置......