I am trying to start a service in ubuntu 16.04. And wrote this .service
file
[Unit]
Description=Executing during boot
[Service]
Type=forking
ExecStart=/home/lokesh/Documents/script.sh
TimeoutSec=30
Restart=on-failure
RestartSec=30
StartLimitInterval=350
StartLimitBurst=10
[Install]
WantedBy=multi-user.target
Alias=startUp.service
Added this service file to /etc/systemd/system/
And this is script file, so basically I am trying to execute a simple operation to write to a file
#!/bin/sh
echo "I'm feeling good" >> txt
echo "how are you" >> txt
Before restart I tested the script file it is working and producing a txt file with some texts in it. And then followed these steps:
chmod u+x /path/to/script/script.sh
sudo systemctl start startUp.service
sudo systemctl stop startUp.service
sudo systemctl enable startUp.service
But after reboot I am supposed to get a new file named txt with few texts. But I am unable to get the output. Is it happening because service is not started or else there is something wrong with service file or script file ?
Regards
txt
needs to be created. So as per your example/home/lokesh/Documents/txt
. I would not be surprised if the file txt is to be found in/root
, assuming your service does start.