3

I am trying to use the GPSD as a server, that is: everything must be done by command line, such as: gpsd --help.

I read the documentation here, which says that.in order to let gpsd work as server, you need to stop or kill the gpsd daemon first.

But I do not know how.

I ran service --status-all and it shows me the list of running daemons, which included gpsd:

[ - ]  gpsd

is it still working or stopped?

I also tried to use start-stop-daemon -k but it did not work, I just get shown the help when I try that.

Zanna
  • 70,465

1 Answers1

2

As you can read from service man page:

service --status-all runs all init scripts, in alphabetical order, with the status command. The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a 'status' command. This option only calls status for sysvinit jobs; upstart jobs can be queried in a similar manner with initctl list.

So, answering your question, YES, it is stopped.

To get the status of any daemon with the following:

start-stop-daemon -T --name gpsd

or if you know gpsd's PID:

start-stop-daemon -T --pid 0123

To kill/stop it, run any (note that the -K is a capital letter):

start-stop-daemon -K --name gpsd
start-stop-daemon -K --pid 4567

Sources:

start-stop-daemon man pages for 14.04

service man pages for 14.04

Zanna
  • 70,465
M. Becerra
  • 3,448
  • @Zanna changed it, hope it's better now – M. Becerra Mar 20 '17 at 10:22
  • seems fine now, +1. Unfortunately it wasn't me who downvoted so not able to fix that – Zanna Mar 20 '17 at 10:28
  • It's okey. I appreciate your feedback, @Zanna, I count on being able to improve my answers/contributions :) – M. Becerra Mar 20 '17 at 10:33
  • @M.Becerra: Thank you for your answer, I tried to use this command start-stop-daemon -K --name gpsd and I received this message:"No gpsd found running; none killed." and I thought daemon has stopped, but when I check the service --status-all it still shows the [ - ] , and I guess gpsd is not working as server yet. – Nate Duong Mar 20 '17 at 13:44
  • @M.Becerra : when I use start-stop-daemon -T --name gpsd to see status, I see nothing. – Nate Duong Mar 20 '17 at 13:51
  • First of all, make sure gpsd is running as a daemon ps -C "$(xlsclients | cut -d' ' -f3 | paste - -s -d ',')" --ppid 2 --pid 2 --deselect -o tty,args | grep ^? | grep gpsd if it is, kill it with sudo killall gpsd and sudo rm /var/run/gpsd.sock , according to the documentation provided by yourself. – M. Becerra Mar 20 '17 at 14:16
  • @M.Becerra : just used ps -C "$(xlsclients | cut -d' ' -f3 | paste - -s -d ',')" --ppid 2 --pid 2 --deselect -o tty,args | grep ^? | grep gpsd and put this command in terminal, then press enter key , I see nothing happen, – Nate Duong Mar 20 '17 at 14:19
  • That means gpsd is not running as a daemon. If you still want to be sure no instance of gpsd is running, do ps ax | grep gpsd, again, if theres no ouput, it means it is not running. – M. Becerra Mar 20 '17 at 14:20
  • @M.Becerra : sudo killall gpsd and sudo rm /var/run/gpsd.sock are used: root@Lab-X230:/home/igor# sudo killall gpsd give me gpsd: no process found, and root@Lab-X230:/home/igor# sudo rm /var/run/gpsd.sock give me rm: cannot remove '/var/run/gpsd.sock': No such file or directory – Nate Duong Mar 20 '17 at 14:21