[SOLVED] A simple cron job will not start
by taylorkh from LinuxQuestions.org on (#4SF3H)
Perhaps it is because it is Sunday morning but this should not be difficult :banghead:
I have setup a script to monitor the state of my VPN connection. Yes, it is marked executable. The script, when run as root, works fine. The system is a Raspberry Pi 3B+ running Ubuntu Mate 18.04. This is the scriptCode:#!/bin/bash
# this job will be run every so often as set in cron
# it will write a timestamp and the status of the ProtonVPN connection to a log
echo `date` >> /var/log/getmyip.log
pvpn --status | tee -a /var/log/getmyip.log
echo >> /var/log/getmyip.log
exitThe crontab entry is as follows (set at every 2 minutes just for testing)Quote:
systemctl shows cron is runningQuote:
The only thing I have observed which is a little strange is the color coding in crontab -e. I am editing with vim. The minute (*/2) is colored purple. The hour, dom and dow are teal blue. However, the mon - which is * - is also colored purple. I have no idea if this is significant. I have retyped the line in case I made some strange typo of the monthly * but the coloration is the same.
For my next trick it occurred to me that Ubuntu does not enable the root account in the way that CentOS for example does. I use sudo su - to access root. I set a password for root to see if that would help. I logged out as sudo su and logged in as root with a plain su. I restarted cron. Still no success. I even rebooted the computer :(
It can't be this hard. What am I overlooking???
TIA,
Ken


I have setup a script to monitor the state of my VPN connection. Yes, it is marked executable. The script, when run as root, works fine. The system is a Raspberry Pi 3B+ running Ubuntu Mate 18.04. This is the scriptCode:#!/bin/bash
# this job will be run every so often as set in cron
# it will write a timestamp and the status of the ProtonVPN connection to a log
echo `date` >> /var/log/getmyip.log
pvpn --status | tee -a /var/log/getmyip.log
echo >> /var/log/getmyip.log
exitThe crontab entry is as follows (set at every 2 minutes just for testing)Quote:
| # m h dom mon dow command */2 * * * * root /usr/local/sbin/getmyip.sh |
| root@t25-magic:~# systemctl status cron a- cron.service - Regular background program processing daemon Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2019-10-13 06:04:51 EDT; 2h 37min ago Docs: man:cron(8) Main PID: 604 (cron) Tasks: 1 (limit: 2152) CGroup: /system.slice/cron.service a""a"604 /usr/sbin/cron -f |
For my next trick it occurred to me that Ubuntu does not enable the root account in the way that CentOS for example does. I use sudo su - to access root. I set a password for root to see if that would help. I logged out as sudo su and logged in as root with a plain su. I restarted cron. Still no success. I even rebooted the computer :(
It can't be this hard. What am I overlooking???
TIA,
Ken