Ubuntu: rc.local di ubuntu 20.04: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
Created page with "Ubuntu 20.04 – start program after boot Edit sudo nano /etc/rc.local #!/bin/bash <your_program>.sh exit 0 make rc.local executable: sudo chmod +x /etc/rc.local..."
 
Onnowpurbo (talk | contribs)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
  sudo nano /etc/rc.local
  sudo nano /etc/rc.local


Isi dengan


  #!/bin/bash
  #!/bin/bash
Line 10: Line 11:


  exit 0
  exit 0
Save file rc.local
Pastikan file script bisa di jalankan dengan chmod
chmod 777 <your_program>.sh
chmod +x  <your_program>.sh


make rc.local executable:
make rc.local executable:


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


edit /etc/systemd/system/rc-local.service:
edit /etc/systemd/system/rc-local.service:
Line 19: Line 29:
  sudo nano /etc/systemd/system/rc-local.service
  sudo nano /etc/systemd/system/rc-local.service


add this content to rc.local.service:
tambahkan content berikut ke rc.local.service:


  #  SPDX-License-Identifier: LGPL-2.1+
  #  SPDX-License-Identifier: LGPL-2.1+
Line 58: Line 68:




check the rc.local status:
check rc.local status:


  sudo systemctl status rc-local.service
  sudo systemctl status rc-local.service

Latest revision as of 10:40, 4 October 2021

Ubuntu 20.04 – start program after boot

Edit

sudo nano /etc/rc.local

Isi dengan

#!/bin/bash
<your_program>.sh
exit 0

Save file rc.local

Pastikan file script bisa di jalankan dengan chmod


chmod 777 <your_program>.sh
chmod +x  <your_program>.sh

make rc.local executable:

sudo chmod +x /etc/rc.local


edit /etc/systemd/system/rc-local.service:

sudo nano /etc/systemd/system/rc-local.service

tambahkan content berikut ke rc.local.service:

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; 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 version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target

enable rc.local by service:

sudo systemctl enable rc-local.service


start rc.local by service:

sudo systemctl start rc-local.service


check rc.local status:

sudo systemctl status rc-local.service