user3525290
user3525290

Reputation: 1617

Restarting multiple services script

The systems admin are preventing me from restarting multiple services sudo systemctl restart service1 service2.

Is there a way to get around this with a bash script.

Upvotes: 1

Views: 3450

Answers (1)

Samuel Kirschner
Samuel Kirschner

Reputation: 1185

Create a file e.g.: touch ~/restart.sh

Make it executable e.g.: chmod 775 ~/restart.sh

Put the following code inside:

#!/bin/sh
for service; do systemctl restart "$service"; done

Run it with sudo ~/restart.sh service1 service2

Upvotes: 1

Related Questions