status -p $pidfile -l $lockfile $prog
This command works on CentOS – /bin/sh shell.
But when I try to run the same command on Ubuntu 14.04 with /bin/bash
shell (or zsh
as well), it throws error,
status: invalid option: -p
Try `status --help' for more information.
How can we pass pidfile location argument to status
command on Ubuntu?
Best Answer
That's the
status()
shell function from/etc/rc.d/init.d/functions
on RHEL/CentOS 6. It's also known asstatusproc()
in the Linux From Scratch world.This tells us that you are doing things very wrongly. You're conflating the special shell helper functions available for use in System 5
rc
scripts with ordinary interactive shell external commands. You're writing System 5rc
scripts on Ubuntu. And you're using PID files and lock files.rc
scripts on Ubuntu Linux. On version 14 one already had upstart; and on version 15 one now has systemd, just like on CentOS 7, RHEL 7, and Debian 8. There hasn't been a good reason for writing System 5rc
scripts on Ubuntu Linux for a long while. And one certainly should not start from there if one is coming to Ubuntu Linux anew. Even if you starting there because you are (mistakenly) trying to bring System 5rc
scripts across from CentOS:status()
shell function across operating systems or even across versions of the same operating system. As noted, it's differently named in LFS. It is not in the "new" LSB support functions from Fedora from 2009. There's not even a mandatorystatus
System 5rc
script action in the Debian Policy Manual in the first place, although the LSB helper shell function library does have a (subtly different)status_of_proc()
helper function.Write an upstart "job file" for Ubuntu version 14, or a systemd "service unit" for CentOS 7, RHEL 7, Debian 8, or Ubuntu 15. Both upstart and systemd provide service status commands:
initctl status
(with a simple shim named juststatus
) andsystemctl status
, respectively. To support them in a job file or a service unit you do not need to do a thing.Further reading
status
function". Packaging:SysVInitScript. 2008. Fedora Project wiki.systemctl
. systemd manual pages. freedesktop.org.