How to run a script as a service in UBUNTU

user526206

I have a script which normally i run using ./myscript.sh(contain java run command) on linux. Now i want to make it as a service so it run automatically after machine restart and if i want to stop and start again simply find the process and kill and start it again from command line.

What i find with quick google search is to place the script in /etc/init.d directory but confusing with one thing that command inside this script using other certificate files which i normally place on same level where this script is place. Do i need to move all others file along with this script under /etc/init.d or is there any better way that i simply mention the path of this script in some file?

agilob

You need to write systemd service file.

Simplest script looks like this:

[Unit]
Description=Virtual Distributed Ethernet

[Service]
ExecStart=/usr/bin/YOUR_SCRIPT

[Install]
WantedBy=multi-user.target

Also you need: systemctl daemon-reload after creating new service.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How, on ubuntu, to run as a service / run under supervision

From Dev

How to run my looping Bash script as a service?

From Dev

How to run PHP script as a background service on AWS?

From Dev

How to run PHP script as a background service on AWS?

From Dev

How to run a Qt program as a service in Ubuntu?

From Dev

How do I run Java as a service on Ubuntu?

From Dev

How to run Ubuntu service on Windows (at startup)?

From Dev

How to make ubuntu service run as specific user

From Dev

How to run .profile inside a shell script in ubuntu

From Dev

How to run python script on terminal (ubuntu)?

From Dev

How to run a script in multiple instances ? ( Ubuntu server )

From Dev

How to run a shell script on Ubuntu-touch?

From Dev

How to run .profile inside a shell script in ubuntu

From Dev

How do I run this bash script in ubuntu?

From Dev

Run NodeJS as a Service on Ubuntu

From Dev

How to trigger a custom script to run whenever a specific systemd service restarts

From Dev

How to trigger a custom script to run whenever a specific systemd service restarts

From Dev

How to run mongodb (extracted from tar.gz) as service in Ubuntu?

From Dev

Systemd configuration to run script as service

From Java

How can I run a Python script from Ubuntu Dash?

From Dev

How to run a bash script while Ubuntu is starting up on tty

From Dev

How can I run a Python script from Ubuntu Dash?

From Dev

How to run a script when suspending/resuming? - Sony VAIO Ubuntu 12.04

From Dev

How to run exec bash command from the bash script in Linux (ubuntu)?

From Dev

How to run a script at screen lock / unlocks in ubuntu 17.10

From Dev

How to launch (run) specific shell script using double click ubuntu

From Dev

How can I run a script on startup on Ubuntu Server 17.10?

From Dev

How to run a script code in Linux Ubuntu when start up?

From Dev

How to write a script and have it run on Ubuntu 16.04 boot

Related Related

  1. 1

    How, on ubuntu, to run as a service / run under supervision

  2. 2

    How to run my looping Bash script as a service?

  3. 3

    How to run PHP script as a background service on AWS?

  4. 4

    How to run PHP script as a background service on AWS?

  5. 5

    How to run a Qt program as a service in Ubuntu?

  6. 6

    How do I run Java as a service on Ubuntu?

  7. 7

    How to run Ubuntu service on Windows (at startup)?

  8. 8

    How to make ubuntu service run as specific user

  9. 9

    How to run .profile inside a shell script in ubuntu

  10. 10

    How to run python script on terminal (ubuntu)?

  11. 11

    How to run a script in multiple instances ? ( Ubuntu server )

  12. 12

    How to run a shell script on Ubuntu-touch?

  13. 13

    How to run .profile inside a shell script in ubuntu

  14. 14

    How do I run this bash script in ubuntu?

  15. 15

    Run NodeJS as a Service on Ubuntu

  16. 16

    How to trigger a custom script to run whenever a specific systemd service restarts

  17. 17

    How to trigger a custom script to run whenever a specific systemd service restarts

  18. 18

    How to run mongodb (extracted from tar.gz) as service in Ubuntu?

  19. 19

    Systemd configuration to run script as service

  20. 20

    How can I run a Python script from Ubuntu Dash?

  21. 21

    How to run a bash script while Ubuntu is starting up on tty

  22. 22

    How can I run a Python script from Ubuntu Dash?

  23. 23

    How to run a script when suspending/resuming? - Sony VAIO Ubuntu 12.04

  24. 24

    How to run exec bash command from the bash script in Linux (ubuntu)?

  25. 25

    How to run a script at screen lock / unlocks in ubuntu 17.10

  26. 26

    How to launch (run) specific shell script using double click ubuntu

  27. 27

    How can I run a script on startup on Ubuntu Server 17.10?

  28. 28

    How to run a script code in Linux Ubuntu when start up?

  29. 29

    How to write a script and have it run on Ubuntu 16.04 boot

HotTag

Archive