"No crontab for root" on WD My Cloud

A follow up question from How to run a cronjob?:

My WD My Cloud did a firmware update this weekend (forgot to turn off auto updating) that caused some settings to reset (including @Nazar78’s hostsdeny script, login key pairs and cron jobs). Most things are recovered, but I can’t get the cron job running again.

When I run crontab -e with my root user, my WD My Cloud replies: “no crontab for root - using an empty one”. That is why I added the hostsdeny.pl script to /etc/crontab (and it seems to be running at reboot).
When I add another cronjob there (*/5 * * * * root /shares/scripts/dyndnsupdate>/dev/null 2>&1) to check if my IP changed, it doesn’t seem to run. I did a cron restart, but that didn’t help.
Alternatively I tried to add the job as a new file in /etc/cron.d called ‘my_cronjobs’ (as mentioned here), but that didn’t help too.
I can run /shares/scripts/dyndnsupdate as a command which works correctly.

How can I make this command run by cron?

Not sure if you’d copy & paste correctly:

It should be:
*/5 * * * * /root/shares/scripts/dyndnsupdate>/dev/null 2>&1

If it still doesn’t work try:
*/1 * * * * /bin/echo `date`>>/root/shares/scripts/test.log

See if the test.log gets updated every 1min else something is wrong with your rootfs, check if the service is running ps -ef|grep cron. A quick reflash might help.

Don’t I have to add the user (‘root’) before the path to the script? The default content of /etc/crontab is:

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
...

That’s why there’s a space between ‘root’ and the path. Both options don’t seem to work though. Neither does:

*/1 * * * * /bin/echo `date`>>/root/shares/scripts/test.log

ps -ef|grep cron shows me 2 lines, so I think it is running.
(By the way: can I check if hostsdeny.pl is running the same way?)

Do I have an issue when crontab -e tells me “No crontab for root”?

The ‘root’ is only for those in etc, the ones for individual crontab doesn’t need it.

When you ran crontab -e then save the edit it should create a new cron for root if it doesn’t exists in the first place.

This is the file for root’s cron /var/spool/cron/crontabs/root (root:root perm 0600). The cron service will look for this path by its user name.

Yes.

I think something messed up in your rootfs. Does restoring the firmware helps (reflash)?

edited: also check that your 2GB rootfs is not 100% full. df -h|grep rootfs This sometimes caused issues.

Where should I save it? If i run crontab -e, it creates a file in a tmp dir.
Is it /var/spool/cron/crontabs/root? It is empty now. Can I just add the formatting * * * * * /path/ ?

Do you mean to install the firmware update again (and thus lose my customisations)?

No, it’s not: rootfs 1.9G 636M 1.2G 35% /

In case this might help. I ran crontab -e on my system. I also got the no crontab for root.
I have no problems with my system.

RAC

When creating a new file it will place it first in the tmp dir then moved
to its final location when you exit and save. Yes you can create a new file
in the spool cron path. It’s actually the same content and format like in
the normal crontab -l you usually see. Give it the same user/group/perm I
mentioned previously.

You could also test if other users has the same cron not running issue by
creating a new cron for that user i.e. crontab -u username -e then add the
log test every minute * * * * * /usr/bin/env>>/tmp/test.log.

The final resort is to reflash, be prepared to redo all customizations.

Noted from Ñážàŕ’s Note3…_\m/

Thanks, good to know!

Just save it to the default tmp location?

I will try the other options before this one :slight_smile:

Thanks!

No that I was describing how the editor treats new creation. If you want to bypass the crontab editor, save it directly to /var/spool/cron/crontabs/root.

How do I run a cron job on my PR4100 nas?

As indicated in your separate thread.

Have you searched through the dedicated WD Pro Series subforum to see if there are any past discussions that may be relevant to your issue/question? This subforum is typically covering issues related to the single bay/single drive My Cloud units.

http://community.wd.com/c/network-attached-storage/wd-pro-series

In particular these two discussions:

http://community.wd.com/t/guide-how-to-make-persistent-system-changes-crontab-etc/201268

http://community.wd.com/t/guide-crontab-demystified/201588