1

I can't get this cron to run.

being new to linux, I really don't know my way around.

Pi 3B+ Debian 9 Stretch PHP 7.0.33 Nginx 1.10.3

Pi has OpenMediaVault ( OMV ) running. Used OMV to create a sharedfolder 'www' which I can access and also map to my PC as a network folder. I have php scripts in the www folder and they execute correctly when accessed from the pC browser.

I want to automate 1 of the php scripts, which I assume is done using crontab.

Used Putty to login to the Pi as user root edit crontab with :

crontab -e

scrolled down and added :

*/1 * * * * /usr/bin/php /mnt/fs/sharedfolders/www/testcode/push2.php

I understand this will run every 1 minute - using that only as a test. I have tested the push2.php code from my browser and it executes as expected without errors.

When cron runs, I get an error report email to my PC ( I assume generated by OMV ) to say :

Could not open input file: /mnt/fs/sharedfolders/www/testcode/push2.php

What am I missing ?

14
  • Verify that the file is actually located at the path that you enter into the crontab. Does ls -ld /mnt/fs/sharedfolders/www/testcode/push2.php actually output anything? Sep 26, 2020 at 8:51
  • no. root@OMVpi1:~# ls -ld /mnt/fs/sharedfolders/www/testcode/push2.php ls: cannot access '/mnt/fs/sharedfolders/www/testcode/push2.php': No such file or directory
    – DaveOB
    Sep 26, 2020 at 8:55
  • So, the file is located elsewhere. Sep 26, 2020 at 8:56
  • how would I find the path to the file ? root@OMVpi1:/# ls -ld /mnt/fs/sharedfolders/www/testcode/push2.php ls: cannot access '/mnt/fs/sharedfolders/www/testcode/push2.php': No such file or directory root@OMVpi1:/# cd /mnt/fs/sharedfolders/www/testcode/ -bash: cd: /mnt/fs/sharedfolders/www/testcode/: No such file or directory root@OMVpi1:/# cd /mnt root@OMVpi1:/mnt# cd/fs -bash: cd/fs: No such file or directory root@OMVpi1:/mnt# ls -a . .. root@OMVpi1:/mnt# pwd /mnt
    – DaveOB
    Sep 26, 2020 at 8:57
  • sorry. new to this platform. how do I paste 'code' so it remains formatted ?
    – DaveOB
    Sep 26, 2020 at 8:58

1 Answer 1

1

The path to the file is /sharedfolders/www/testcode/push2.php, not /mnt/fs/sharedfolders/www/testcode/push2.php.

From comments, it appears as if you're put into a chrooted environment under /mnt/fs when you log in using ssh. This is why the pathname of the file starts with /sharedfolders rather than with /mnt/fs. The /mnt/fs directory is the root directory of your ssh session.

1
  • Thank You @Kusalananda. I really appreciate your expert advice and solution and explanation.
    – DaveOB
    Sep 26, 2020 at 9:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .