4

I've just set up my first cron-jon to run a stock script every night. Running it manually works fine.

It's stored in /admin/stock_update.php

The command i'm running is /usr/bin/php -q /admin/stock_update.php

But I'm getting emails saying no input file is specified? Any ideas?

Cheers

s.poole
  • 131
  • 2
  • 17
  • Are you positively sure that there is a top-level directory called `/admin` in your server? It isn't a convention in Linux boxes as far as I know. Remember that command-line utilities expect paths on disk, not web site URLs. – Álvaro González Jun 07 '16 at 11:53
  • @ÁlvaroGonzález I'm not entirely sure, I don't have much experience in this type of stuff. I'm just using the path from my FTP. – s.poole Jun 07 '16 at 12:06

2 Answers2

5

Network services almost never expose actual paths on the server's hard disk drive and even if they could it isn't a behaviour you can rely on. So the fact that your file is located at /admin/stock_update.php in the FTP server doesn't say much about actual location on disk, which is what local command-line utilities expect.

In PHP, you can find path on disk of current file with the __FILE__ magic constant. You can create a test script:

<?php
var_dump(__FILE__);

... upload it to the same FTP location and execute through the web server. If that's not an option because files in your FTP account in not visible from the web you can run the file from cron and check the email.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • Hi Alvaro, thanks that makes a lot of sense. I've updated my cron to the correct server path, now I'm getting a different error. 'Can't read tmp file to save stock in' – s.poole Jun 07 '16 at 12:42
  • @s.poole I you get a custom error from your code that means your file is finally running. Glad you got it sorted out. – Álvaro González Jun 07 '16 at 14:02
0

Do you have CloudLinux kernel installed on that server and CageFS filestyem? If yes try running this:

cagefsctl -w cpaneluser; cagefsctl -m cpaneluser

Then try running the cron again

Bogdan Stoica
  • 4,349
  • 2
  • 23
  • 38