Due to some bugs in CUCM (MTP resources leaking) or some bugs in UCCX (API error 500), we have to periodically reboot the systems.
We can able to automate it by using the Python script.
1. Install 'Ubuntu 20'


2. Install 'Windows Terminal'


3. Start the 'Windows Terminal' and open 'Settings'.

4. Set 'Default Profile', 'When the Terminal starts' and click Save.

5. Set 'Never close automatically' and press 'Save'

6. Turn on the 'Windows Subsystem for Linux'

7. Start the 'Windows Terminal'.

8. Create the file reboot.py

9. Type the following code
import pexpect
import sys
import time
server_ip = "ccx.winncom.uz"
server_user = "CCXAdm"
server_pass = "ZAQ!2wsx"
child = pexpect.spawn(f'ssh -o "StrictHostKeyChecking=no" {server_user}@{server_ip}',encoding='utf-8')
child.delaybeforesend = 5
child.timeout=1200
child.logfile = sys.stdout
child.expect("CCXAdm@ccx.winncom.uz's password: ")
child.sendline(server_pass)
child.expect('admin:')
child.sendline('utils system restart')
child.expect('Enter (yes/no)?')
child.send('y')
child.send('e')
child.send('s')
child.sendline()
print ('Restart command successfully sent.')
time.sleep(600)
10. For testing type 'python3 reboot.py'

11. Enable and start cron.
sudo systemctl enable cron
sudo service cron start
12. Check if the cron started.
pgrep cron
13. Setup the cron.
crontab -e

In this example, the file reboot.py will start every Monday at 3:00 a.m.
14. Give the rights
chmod +x reboot.py