Jump to content

Script working manually but not as Cron Job


Dweezel

Recommended Posts

I've got a script that's been running away happily as a cron job for the last few days, but it's suddenly decided to stop working. When I run the script manually it works perfectly, but not when I run it as a cron job. I've done some debugging and I've found that the cause of the problem appears to be an ftp_get function that I'm using. I'm guessing I need to either change a file path, or a file permission, but I'm not sure to what. Here's the info:

 

        $local_dir = '../../col_protected/';

       $c = ftp_connect('www.mydomain.net')     or die("Can't connect");

ftp_login($c,'ftp_username','ftp_password')     or die("Can't login");

ftp_get($c, $local_dir.$filename, FTP_ASCII) or die("Can't transfer");

 

The FTP connect and login are still working fine, it's the ftp_get that's causing the problem. The '../../col_protected/' directory is on the same level as the public_html (ie. outside the public_html) with file permissions set to 777.

 

The cron is running at /home/username/public_html/col/proc1.php

 

 

Can anyone advise please?

 

Many thanks,

Chris

 

Thanks to both of you for your help. I tried every possible combination for the absolute path but couldn't get it to work. In the end I used Thorpe's plan B and moved the col_protected directory into the same directory as the script. I was hoping to keep it oustide the public_html, but I'll have to just http block it via htaccess.

 

Many thanks,

Chris

Have you got access to a shell? If so, just go to the directory where the script resides then issue the pwd command, this will print the path.

 

From here, it looks like its in your home directory.

 

/home/username/col_protected

 

You should also move your script into your home directory.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.