Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Can I restart my UNIX server through Powershell or SSH activity pack

Manju Shree
Tera Expert

I have a requirement to restart a UNIX server through workflow activity pack. How and where can I run a UNIX command to restart a server.

 

Kindly provide you inputs.

 

Best Regards,

Manjushree

2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

Hello @Manju Shree,

 

To restart a Unix server through a workflow activity pack, you'll typically use a "Run Command" or "Execute Command" activity within the workflow, and then execute the appropriate command on the target serverFor example, on most Linux systems, you'd use sudo reboot or sudo systemctl rebootOn Solaris or other Unix systems, you might use shutdown -r nowThe key is to ensure the workflow has the necessary credentials (e.g., sudo access) to execute the command on the remote server. 
Here's a more detailed breakdown:
1. Identify the Command:
  • sudo reboot or sudo systemctl rebootCommonly used on Linux systems that use systemd. 
     
  • shutdown -r nowAnother option for restarting on Linux or Solaris. 
     
  • shutdown -r +0 or shutdown -r HH:MMUsed to schedule a restart at a specific time (now is equivalent to +0). 
     
  • init 6A less common but still valid method, particularly in older systems.
     
2. Workflow Configuration:
  • Choose the appropriate activity:
    Most workflow engines will have an "Execute Command" or "Run Command" activity.
  • Specify the target server:
    You'll need to configure the activity with the hostname or IP address of the Unix server.
  • Provide credentials:
    The activity will need credentials that have sufficient permissions to execute the restart command. This usually means using a user account with sudo rights or directly logging in as root.
  • Enter the command:
    Input the appropriate restart command (e.g., sudo reboot) into the activity's command field. 
     
3. Running the Workflow:
  • When the workflow executes the activity, it will connect to the Unix server, authenticate with the provided credentials, and then execute the command.
  • The server will then begin the restart process. 

If this is helpful, please hit the thumbs up button and accept the correct solution by referring to this solution in future it will be helpful to them.

 

Thanks & Regards,

Abbas Shaik

Pratiksha
Mega Sage
Mega Sage

Yes, you can do it. if this is after an alert then you can use alert manamgenet rule. one flow can create incident and based on response you can write the remediation. 

 

If not related to alert then simply you can write a flow. You will need mid server to connect to device. Look into mid server script files. Their you can create power shell script and restart the device.