UBUNTU – 12 – 04 – Criar script para rodar um comando no inicializar.

sudo vim /etc/systemd/system/rc_local.service
——————————————————
[Unit]
After=network.service
[Service]
ExecStart=/usr/local/bin/rc_local.sh
[Install]
WantedBy=default.target
—————————————————–

vim /usr/local/bin/rc_local.sh
—————————————————-
#!/bin/bash

date > /root/disk_space_report.txt
du -sh /home/ >> /root/disk_space_report.txt

—————————————————–

sudo chmod 664 /etc/systemd/system/rc_local.service
sudo chmod 744 /usr/local/bin/rc_local.sh

sudo systemctl daemon-reload
sudo systemctl enable rc_local.service

sudo systemctl status rc_local.service