Linux Nightmare running Cron job

Shindig

DW Regular
Joined
Apr 27, 2006
Messages
1,315
Reaction score
214
Location
Auckland, New Zealand
I have my Raspberry setup as a SSH terminal, works a treat. I can log in as pi (user) and run wakeonlan to start my windows server etc.

I have a couple of scheduled tasks setup on my server to take a backup of movies,music,photos.
Thinking, rather than leave server on I will get raspberry pi and schedule a wakeonlan command.

Looking at cron I thought easy.

So if I wanted to wakeup my server I log in as pi all as normal I can run wakeonlan -f machine from command. Sorted

setup cron I was under the impression of typing

crontab -e
add a line with the necessary timing * * * * * wakeonlan -f machine OR wakeonlan MACADD

but the thing doesnt work.
If I add a test line in
* * * * * echo "Cron Worked $(date)" >> /tmp/cronworked.txt it works and I see the txt file. Remove the txt file, it comes back! Ace CRON is running.

Really unsure why, trying to run wakeonlan as the user pi from cron fails, when I can manually type it in (as pi) as it works.

from syslog
Jul 8 08:22:01 raspberrypi cron[989]: Error: bad username; while reading /etc/crontab
Jul 8 08:22:01 raspberrypi /usr/sbin/cron[989]: (*system*) ERROR (Syntax error, this crontab file will be igno$
Jul 8 08:22:01 raspberrypi /usr/sbin/cron[989]: (pi) RELOAD (crontabs/pi)
Jul 8 08:22:01 raspberrypi /USR/SBIN/CRON[1174]: (pi) CMD (wakeonlan -f machine >/dev/null)

guys any ideas???
 
Last edited:
As you probably know, it could be a few things but I'm favouring either user pi hasn't got the right perms within cron or, due to restricted environment, you need to put full paths to commands...

I assume those timings are example only - you don't want to run every minute???
 
So I got it sorted.
Entered in the full path to wakeonlan but also added pi to the crontab group in /etc/group.

Cheers for the heads up around the full path, I am sure I had added it before but hadn't worked.
Anyway... on to remote drive spinup before synctoy kicks in.
 
Back
Top