How to force quit and restart a service every hour?

The Underlying Problem

This is rather specific to my machine but basically, because of how my Mac, dock, & keyboard are connected, my keyboard software (Corsair iCUE) will occasionally freeze/hang until I go into activity manager and force quit it.

It happens once every day or 2 and the specific cause is not known, but it has never happened within a few hours of me restarting the service.

As a result, none of my macros, media keys, custom scripts, lighting effects, etc. work while iCue is frozen.

The Desired Workaround

Given how specific this issue is to my setup and that iCUE is in beta for Mac, I don't expect Corsair to fix it anytime soon.

Also, given that this issue never happens when I have recently restarted the service, my ideal workaround would be to simply force-restart it every hour or so. (It's a lightweight service, so restarting should be near-instant)

My Question: How can I force quit and then restart a service every hour?

Please let me know if I can provide any additional information to help!


In Terminal, ps -ef to identify a search string for the process you want to kill.

Then the script can find it by

ICPID=$(ps -ef | grep "searchstring" | awk '{print $2}') # find the PID

kill -9 $ICPID                                           # kill it

<full path to executable>                                # restart it

The 9 is the signal to send to the process. From the man page:

Some of the more commonly used signals:

 1       HUP (hang up)
 2       INT (interrupt)
 3       QUIT (quit)
 6       ABRT (abort)
 9       KILL (non-catchable, non-ignorable kill)
 14      ALRM (alarm clock)
 15      TERM (software termination signal)