Bash script help


Recommended Posts

Hi,

 

I am looking to write simple script so when I run it, if both are running it stops them, if they are not it starts them, this is the script I have so far:

#!/bin/bash
 
 
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

How can I make it so if they are loaded it unloads them if its not it loads them? like a condition?

Link to comment
Share on other sites

like this

 

so this one check to see if gedit is running

#!/bin/bash

if ps aux | grep "[g]edit" > /dev/null
then
    echo "Running"
else
    echo "Stopped"
fi
  • Like 2
Link to comment
Share on other sites

This topic is now closed to further replies.