Fedora 22 (15 or later) boot script

Source: Internet
Author: User

Some time ago made a website Btdog magnetic and Btdog TV Live. DHT crawlers need to consume more resources, the original server is not enough, so that they use a computer to build a server, using the FEDORA22 system. Some auto-start scripts are automatically written in Fedora22, but they are not always found. Toss it down and discover the original Fedora starting from 15, the system initialization software began to shift from Initscript to SYSTEMD mode, Originally to write boot script is generally written in rc.local inside, but now rc.local no longer exist, but Systemd still have rc-local service.

Edit/usr/lib/systemd/system/rc-local.service 

# thisfileis part of systemd.## systemd is FreeSoftware; You can redistribute it and/or modify it# under the terms of the GNU Lesser general public License as published by# the free software Foundation ; Either version2.1of the License, or# (at your option) any later version.# this unit gets pulled automatically into multi-user.target by# systemd-rc-local-generatorif/etc/rc.d/rc.local is executable. [Unit] Description=/etc/rc.d/rc.local compatibilityconditionfileisexecutable=/etc/rc.d/Rc.localafter=Network.target[service]type=Forkingexecstart=/etc/rc.d/rc.local starttimeoutsec=0Remainafterexit=yes

  We just need to create a new file/etc/rc.d/rc.local and then add our own script.

New rc.local  

Touch /etc/rc.d/rc.local

Vim/etc/rc.d/rc.local

#!/bin/bash# Below is the script you need to execute

#####################################

  Assign to executable permissions

chmod +x/etc/rc.d/rc.local

 Then use SYSTEMD to boot from

Systemctl Enable Rc-local.service

  The prompt error is as follows: 

The unit files has a no [Install] section. They is not meant to being enabledusing systemctl.  Possible reasons for have this kind of units are:1) A unit May is statically enabled by being symlinked from another Unit ' s   . wants/or. requires/ directory.2) A Unit's purpose may is to act as A helper for some other unit which ha s   a requirement dependency on it.3) a unit may is started when needed via activation (socket, path, timer,
        
         d-bus, Udev, scripted systemctl call, ...).
           

  At this point, we need to add the [Install] zone to the/usr/lib/systemd/system/rc-local.service to tell Systemd to start the script when the user starts or when the graphics start

Edit/usr/lib/systemd/system/rc-local.service

# thisfileis part of systemd.## systemd is FreeSoftware; You can redistribute it and/or modify it# under the terms of the GNU Lesser general public License as published by# the free software Foundation ; Either version2.1of the License, or# (at your option) any later version.# this unit gets pulled automatically into multi-user.target by# systemd-rc-local-generatorif/etc/rc.d/rc.local is executable. [Unit] Description=/etc/rc.d/rc.local compatibilityconditionfileisexecutable=/etc/rc.d/Rc.localafter=Network.target[service]type=Forkingexecstart=/etc/rc.d/rc.local starttimeoutsec=0Remainafterexit=yessysvstartpriority= About [Install]wantedby=multi-user.target

 OK, then use SYSTEMD to boot from

 Then view the startup status

#systemctl Status rc-Local.service RC-local.service-/etc/rc.d/rc.local compatibility loaded:loaded (/usr/lib/systemd/system/rc-local.service; Vendor preset:disabled) Active:active (exited) since a -- .- A  -: at: atCST; 28min ago6 Month A  -: at: atBtdog systemd[1]: starting/etc/rc.d/rc.local compatibility ... June A  -: at: atBtdog rc.local[3973]:/etc/rc.d/rc.local: Line 4: [Install]: Command not found June A  -: at: atBtdog systemd[1]: started/etc/rc.d/rc.local compatibility.6 Month A  -: -: -Btdog systemd[1]: started/etc/rc.d/rc.local compatibility.6 Month A  -:Panax Notoginseng: toBtdog systemd[1]: [/usr/lib/systemd/system/rc-local.service: -] Support forOption sysvstartpriority=... ignoredhint:some lines were ellipsized, use-L to showinchFull.

  Start Success ~ ~

Fedora 22 (15 or later) boot script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.