Issue
restarting apache via service command :
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
I want to be able to get the same output without using the "service" command.
the following command works but does not print anything.
/usr/sbin/httpd -k restart
Solution
The "service" command runs the /etc/init.d/httpd
script, this script restarts httpd and prints the info.
With /usr/sbin/httpd -k restart
, you are restarting httpd without printing anything.
I want to be able to get the same output without using the "service" command.
Option 1
Run the httpd init script:
/etc/init.d/httpd restart
Option 2
You could create a script like the following:
#!/bin/bash
echo "Restarting httpd..."
/usr/sbin/httpd -k restart
Name it 'restart_httpd.sh
', for example, and make it executable:
chmod +x restart_httpd.sh
Run it:
./restart_httpd.sh
Answered By - sergej