Let’s make it simple, i just got order from my officer to reboot one unit EX2300 every month. I’m not very sure why, but it’s ok. I just make a cronjob script inside the switch. The switch need to reboot by it self every month on Saturday morning at 2:30 am. So, what do i need? I need a coffee!!

Prepare the script

First thing i need to plan, what command do i need and how i want to implement it. The command that i need is “request system reboot at now” and also i need some timestamp to put inside the log. This script must be run on shell.

Access your shell mode on the switch and go to /var/tmp

netadmin@EX2300T4-A-GR1-1> start shell 
% su
root@EX2300T4-A-GR1-1:RE:0% cd /var/tmp
root@EX2300T4-A-GR1-1:RE:0% pwd

Create a new bash script using vi editor

vi reboot_script.sh

Paste this script inside the file.

echo `date "+%Y-%m-%d %H:%M:%S"`
cli show system uptime
cli request system reboot at now
echo "=============="

echo `date “+%Y-%m-%d %H:%M:%S”` will show the timestamp.
cli show system uptime. Will show you the current uptime for the switch
cli request system reboot at now. Will restart the switch without asking permission.

If you not familiar with vi editor, you can google it how to use vi editor. After you finish you may save the script.


Type ‘crontab -e’ to edit the cron file. If you get error, please run su command to enter admin mode.

% crontab -e
crontab: seteuid: Operation not permitted
% su
root@EX2300T4-A-GR1-1:RE:0% crontab -e
*/30 2 * * Sat [ $(expr $(date +%W) % 2) -eq 1 ] && sh /var/tmp/reboot_script.sh >> /var/tmp/reboot.log

If you want to change the schedule, you may check this crontab guru or cron help

You can check the log by cat reboot.log

cat reboot.log
2021-10-18 22:24:00
Current time: 2021-10-18 22:24:00 MALT
Time Source:  NTP CLOCK 
System booted: 2021-10-18 22:24:00 MALT (00:27:58 ago)
Protocols started: 2021-10-18 22:24:00 MALT (00:24:54 ago)
Last configured: 2021-10-18 21:24:00 MALT (00:01:39 ago) by netadmin
 10:24PM  up 28 mins, 1 users, load averages: 1.29, 0.72, 0.65
Shutdown NOW!
[pid 5603]