sudo nano /etc/rc.local
I have run the above and added the path below. HDD_temp is an executable text file.
/home/matthew/@/HDD_temp/HDD_temp
However, the file is not run at system startups. How can I run it at system startups?
sudo nano /etc/rc.local
I have run the above and added the path below. HDD_temp is an executable text file.
/home/matthew/@/HDD_temp/HDD_temp
However, the file is not run at system startups. How can I run it at system startups?
You can use cron
and and the script to be run at @reboot
.
To edit: sudo crontab -e
.
Then add the task:
@reboot the_script_to_be_run
sleep 30 && sudo service fancontrol restart
. Notice that you need to configure sudo
, so that it doesn't require authentication.
–
Mar 02 '19 at 12:18
sleep 30 && sudo service fancontrol restart&
at the beginning of the script.
–
Mar 02 '19 at 13:34
sudo
not to ask for your password. Or put the script into root's crontab.
–
Mar 05 '19 at 05:14
crontab -e
, or simply sudo crontab -e
.
–
Mar 05 '19 at 05:18
sudo mail
.
–
Mar 05 '19 at 05:36
You can also make a systemd "service". For example:
Create an empty text file using vi, nano or whatever:
[Unit]
Description=My service
[Service]
ExecStart=/path/to/my/script.sh
ExecStop=/usr/bin/killall script.sh
# Useful during debugging; remove it once the service is working
StandardOutput=console
[Install]
WantedBy=multi-user.target
Save it under /etc/systemd/system/myscript.service
or any other name,
Then run:
sudo systemctl start myscript
You can check the service with sudo systemctl status myscript
and stop with sudo systemctl stop myscript
. To make it starts after boot run systemctl enable myscript
as root.