Skip to main content
edited body
Source Link
coltsfan95
  • 39
  • 1
  • 2
  • 5

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc./profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestart1.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc.profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestart1.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc/profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestart1.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.

added 1 character in body
Source Link
coltsfan95
  • 39
  • 1
  • 2
  • 5

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc.profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestartvpnrestart1.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc.profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestart.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc.profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestart1.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.

Source Link
coltsfan95
  • 39
  • 1
  • 2
  • 5

Shell script not running with Cron, but runs manually

I feel like I have tried everything, my search history is about 20 pages deep on google trying to fix this and nothing works. Basically I have a script that checks if my tun0 interface exists, and if it is missing, the computer will restart. Here's the code:

#!/bin/bash
. /etc.profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if echo `ifconfig` | grep -q "tun0"
then echo ""
else
    reboot
fi

The script itself runs fine if I invoke it at a terminal using its path:

/scripts/vpnrestart1.sh

I've added this at the top of crontab -e:

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

My cron task looks like this:

* * * * * /scripts/vpnrestart.sh

Permissions are all fine on the script itself and it can be executed without using sudo. As I mentioned, it runs from the terminal just fine and works as designed. But if I put it in cron and remove the tun0 interface, nothing ever happens.