LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2016, 09:26 AM   #1
fkitdco
LQ Newbie
 
Registered: Dec 2015
Posts: 4

Rep: Reputation: Disabled
run a command while debian server boot


hi
i want to run a command while starting up debian
(no need sh file , just command)
please help me
 
Old 05-05-2016, 09:33 AM   #2
dolphin_oracle
MX Linux
 
Registered: Dec 2013
Posts: 399

Rep: Reputation: Disabled
well, it depends on the command, and when you want to run it.
 
Old 05-05-2016, 09:38 AM   #3
fkitdco
LQ Newbie
 
Registered: Dec 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
the command is
opensips
, after login as root and run this command , opensips work well , i want to run it while system boot as root
 
Old 05-05-2016, 09:55 AM   #4
dab1414
Member
 
Registered: May 2011
Location: OK, USA
Distribution: Slackware 14.1_64
Posts: 71

Rep: Reputation: 51
Quote:
Originally Posted by fkitdco View Post
hi
i want to run a command while starting up debian
(no need sh file , just command)
please help me
I haven't used systemd in awhile, but if memory serves this should do. Maybe have to verify location of command.

Code:
cat /etc/systemd/system/opensips.service
[Unit]
Description=Starts opensips

[Service]
Type=oneshot
ExecStart=/usr/sbin/opensips
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Code:
systemctl enable opensips
Code:
systemctl start opensips
 
Old 05-05-2016, 10:53 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,423

Rep: Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103
Add your command including the full path to the /etc/rc.local file. Make sure it is executable and it will run as the last command in the startup routine. Might have to enable the service (assuming systemd) via

systemctl enable rc.local.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Vino-server at boot (GDM3 DEBIAN SQUEEZE) jonathanb Linux - Software 3 02-21-2012 02:56 AM
Debian 6 - Run Level - Boot to Command LIne jv2112 Linux - Newbie 3 03-20-2011 07:00 AM
run command on debian boot? aktivemac Debian 12 02-29-2008 08:59 PM
Run Command After/During Boot revof11 Linux - General 4 06-02-2006 03:26 PM
Run a command at boot Ace2005 Debian 3 07-24-2005 10:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration