PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] How to start a service on Ubuntu 20.04 via systemctl?

 May 15, 2022     systemctl, ubuntu     No comments   

Issue

I have an instance running ubuntu 20.04. I've logged into the console via the online GUI 'connect' tool. On the ubuntu instance I've added a service file with below contents:

linux_setup:

[Unit]
Description=my app
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=ubuntu
ExecStart=python3 app.py file:///$PWD/LOG --port 8080

[Install]
WantedBy=multi-user.target

I now want to start this within my instance. To do so I perform the below steps:

ubuntu@ip-172-31-1-50:~$ ls
app-folder
ubuntu@ip-172-31-1-50:~$ cd app-folder
ubuntu@ip-172-31-1-50:~/app-folder$ ls
LICENSE  LOG  README.md  datasource  app.py  linux_setup.service  requirements.txt  test
ubuntu@ip-172-31-1-50:~/app-folder$ sudo systemctl start linux_setup
Failed to start linux_setup.service: Unit linux_setup.service not found.
ubuntu@ip-172-31-1-50:~/app-folder$ 

As evident, it seems like the linux_setup.service is not found - yet it should be there. How do I correctly start up this setup file?


Solution

I ended up using below method to download a unit file and deploy it:

sudo wget [your_file_url]
sudo cp service_name.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start service_name
sudo systemctl enable service_name
sudo journalctl -f -u service_name


Answered By - mfcss
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing