Hello,
I believe the best way in this case to automate your task is to create a script and run it as a systemd service or a cron job.
Code:
#!/bin/bash
systemctl restart service1 # restart services on execution.
systemctl restart service2
command1
command2 # Your automated commands (Just like in the terminal)
main subroutines # More commands
main subroutines
exit 0 # Exit on Success
and save it as "yourscriptname".
furthermore,
run "chmod +x yourscriptname" (without quotes)
and copy it over to your /usr/bin directory if you want to run it directly from the command line as "yourscriptname"
and/or as a cron job:
http://www.cyberciti.biz/faq/how-do-...-or-unix-oses/
I hope this suggestion helps you in your situation of automation.
Sincerely,
donald3.heckel