2

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
w3shivers
  • 390
  • 4
  • 18
  • What command do you use for executing manually? – Erki Aring May 23 '16 at 07:46
  • @ErkiA meant to be via browser not command line. I edited question to reflect that. – w3shivers May 23 '16 at 09:04
  • You can add `#!/usr/bin/php` before ` – Alex May 24 '16 at 09:50
  • May be interesting for you to go through the common causes in [Debugging crontab](http://stackoverflow.com/tags/crontab/info): are you mentioning the binary? is cron running? did you try with something simple like `* * * * * echo "hello" >> /tmp/random.file` and see if this works? – fedorqui May 26 '16 at 07:45

1 Answers1

3

/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

Erki Aring
  • 2,032
  • 13
  • 15
  • Thanks for your answer, it did not work quite the way I intended it to work, but did lead me in the right direction. So I suggested an edit to your answer with the alternative that did work. – w3shivers May 26 '16 at 09:28