• Post Reply Bookmark Topic Watch Topic
  • New Topic

System service status check on redhat6.7  RSS feed

 
nishu midha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed postgresql . which is installed as system service (using systemctl) . I have written below code in service start script . i ts running fine in centos 7. But not running on rhel 6.7 . anyone please help, how to do this in rhel 6.7.

If [systemctl is-Active postgresql.service=="active"] then; echo -n "server is running " else echo -n "service not running"
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Remember about case sensitivity, it's systemctl is-active what you have on mind, not systemctl is-Active . The same goes for if, your code has it as a capital letter. You also need fi to close the if. And don't forget about semicolons, as you wrote everything in one line.

 
nishu midha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I have put Everything in one line sorry for that . But I have tried that as per syntax and semantics . it is. Working in centos 7. But not working in rhel6.7 because systemctl is not supported in rhel6.7. . please help how it can be done in rhel6.7
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah I see. Try to replace systemctl command with service postgresql status. Check what value it returns and use that in your script. systemctl is for systemd init system which wasn't in rhel6
 
nishu midha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is being used in rhel6 in place of systemctl
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use service command, ie. service postgresql start.

Enter man service command to get description and available options.
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Red Hat/CentOS version 6, as most Linux distros historically have done, uses the SysV init subsystem. Under that architecture, services are controlled by scripts located in the /etc/init.d directory. Automatic start/stop of services is managed by assigning aliases in various runlevel control directories (/etc/rc.2, rc.3, and so forth). The preferred way to assign these runlevels is to use the "checkcfg" command (for example, "chkconfig cups on", "chkconfig --level ntpd").

There were flaws in SysV init. It was difficult to allow for systems that depended on other systems and resources. So in Red Hat/CentOS version 7, SysV init was replaced with systemd. The systemd system has been a controversial move. Unlike SysV init, which, following longstanding Unix/Linux practice was something that if you didn't like, you could replace with something you did, systemd is rigidly embedded within the OS. It also usurps features outside of the scope of actual service control - for example, instead of plug-replaceable separate system logging subsystems, systemd now owns the logging function and logs to a binary file format instead of text like the older loggers did. One problem I discovered with binary log files before I ever started working with Linux (and that's been a LONG time), is that instead of being processable directly via the wealth of text-processing tools that Linux inherited from Unix, you have to use the systemd logger to first translate the binary logs to text format if its built-in solutions aren't sufficient. A personal gripe of mine is that as shipped, the binary logger will also eat your disk. The old logrotate facilities don't apply to it either.

And, to add insult to injury, systemd adheres to the recent trend of providing "improvements" while removing critical features that had been in the older systems.

I can see the potential in systemd, but it has so many objectionable qualities in its current form - both technical and in the fact that its authors consider any criticism of what it does to be indicative of deficiencies in the critics and not of their product - that I have avoided migrating to version 7 for that one reason alone. I only use version 7 where there is no possible way to do what I want on a version 6 system. I'm hoping Version 8 will be kinder and gentler, but so far, I'm not optimistic.
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upstart is an option. But they're still using init scripts.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!