Featured image of post How to Disconnect and Reconnect Vyos Pppoe0 Interface With Crontab

How to Disconnect and Reconnect Vyos Pppoe0 Interface With Crontab

Create vbash script

Create folder

1
mkdir /config/scripts/reboot_pppoe_connection

Create script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
mv /config/scripts/reboot_pppoe_connection/reboot_pppoe_connection.sh{,.bak}
ls /config/scripts/reboot_pppoe_connection/
tee -a  /config/scripts/reboot_pppoe_connection/reboot_pppoe_connection.sh << "EOF"
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
logfile=/var/log/reconnect_pppoe0.log

echo "==================================" >> ${logfile}  2>&1
date '+%Y-%m-%d %H:%M:%S' >> ${logfile} 2>&1
run show interfaces  | grep -A 2 ppoe0  | tee >> ${logfile} 2>&1
run disconnect interface pppoe0  | tee >> ${logfile} 2>&1
run connect interface pppoe0 | tee >> ${logfile} 2>&1
echo "sleep 3 second..." >> ${logfile} 2>&1
sleep 3
run  show interfaces  | grep -A 2 ppoe0 | tee >> ${logfile} 2>&1
date '+%Y-%m-%d %H:%M:%S' >>  ${logfile} 2>&1
echo "==================================" >> ${logfile} 2>&1
exit
EOF

Chmod +x to vbash script

1
chmod +x /config/scripts/reboot_pppoe_connection/reboot_pppoe_connection.sh

Create task with vyos command

1
2
3
4
5
config
set system task-scheduler task RUN_SHUTDOWN_PVE crontab-spec '00 3 * * *'
set system task-scheduler task RUN_SHUTDOWN_PVE executable path '/config/scripts/reboot_pppoe_connection/reboot_pppoe_connection.sh'
commit
save
Built with Hugo
Theme Stack designed by Jimmy