2

I'm trying to run rtcwake from crontab using this command:

0 2 * * * /usr/sbin/rtcwake -u -m disk -t $(date +\%s -d 'today 0730') >> /tmp/rtcwake.log 2>&1

So, as you can see from this command, I'm telling the cron job to execute rtcwake at 2am every day and for rtcwake to wake itself at 7.30am the same day using local time (I'm running the cron job from the root account)

This is not working unfortunately, I get this message from the log:

rtcwake: wakeup from "disk" using /dev/rtc0 at Fri Sep  1 06:30:00 2017 
rtcwake: write error

Could someone explain what I need to do, I thought running this from the root account would solve any permission errors or could this be a space issue (albeit, i have 7tb of space but maybe the drive is too small)?

Note: If, as root, I run the rtcwake command itself for a shorter period, it works fine, even from the cron.

I'm running 16.04 ubuntu server.

  • Can you clarify that with the root user, if you run /usr/sbin/rtcwake -u -m disk -t $(date +\%s -d 'today 0730') >> /tmp/rtcwake.log 2>&1 it works? Or same command, changing only the "today time"? – Katu Sep 1 '17 at 9:04
  • I change the date to say 5 minutes from the executed time, so say as of 10:10, I would set 'today 10:15' to test, and it works fine – Chris Sheppard Sep 1 '17 at 9:09
2

The write error was a strange one, I couldn't fully fix it but I've solved my problem, instead of running this command:

0 2 * * * /usr/sbin/rtcwake -u -m disk -t $(date +\%s -d 'today 0730') >> /tmp/rtcwake.log 2>&1

I run this command:

0 2 * * * /usr/sbin/rtcwake -u -m off -t $(date +\%s -d 'today 0730') >> /tmp/rtcwake.log 2>&1

off is not supported by all systems so it's best you trial and error it. Server has been doing what I want now for 2 nights.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.