Search code examples
phpcronputtycron-tasknas

Can’t get cron job working on ASUSTOR NAS model AS-302T


I’ve been struggling for weeks now trying to find any info on how to successfully setup a cron on my Asustor NAS, and would really appreciate any help.

Here is what I have done via my favourite SSH program putty. I added my cron in the following file:

/var/spool/cron/crontabs/root

The cron line added to the above file should run at 21:15 each night and looks as follows:

15 21 * * * * /volume1/Web/test/cron.php

After adding the above line I restarted the cron daemon (I think) with the following command:

/etc/init.d/S41crond restart

I’m not sure what I’m doing wrong, but it seems I just cannot get this cron to work.

Also if anyone can give me a good site that can help me regarding my Asustor NAS in general it would be much appreciated. I want to change a lot of settings like my database session duration, cahce and so on and I can’t find any real helpful info online. Unfortunately Asustor’s online help is really not of much help to me.

BELOW IS ONLY ADDITIONAL INFO ON CRON.PHP FILE
The cron.php file is really a simple file that I’m currently just using to see if I can get the cron working, here is the code inside the cron.php file:

<?php
$dateFile = date('Y-m-d_H-i-s').'.txt';
fopen($dateFile, "w");
?>

The above code works 100% when executed manually via browser.

Also works when following commands are excuted via Putty:

cd /volume1/Web/test/
php cron.php

Solution

  • /volume1/Web/test/cron.php is a script, not an executable. Script can only be interpreted by its interpreter, PHP in this case. Correct crontab entry in this case would be something like this:

    15 21 * * * php /volume1/Web/test/cron.php