• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
running cronjob in Linux CLI

#1
I am trying to setup to run an app  (which has no UI) every Saturday night at midnight. This is the line I came up with fo the crontab file:

59 0 * * 6 /opt/bitnami/apache2/htdocs/sub_crud/application/controllers/cron_job

I don't know if this will work but I want to run it right now to see. I was thinking I might need:

59 0 * * 6 php -f /opt/bitnami/apache2/htdocs/sub_crud/application/controllers/cron_job

When I run the  line below from the CLI in a putty terminal
php -f /opt/bitnami/apache2/htdocs/sub_crud/application/controllers/cron_job.php


Code:
XDebug could not open the remote debug file '/opt/bitnami/apache2/logs/xdebug.log'.

No direct script access allowedbitnami@ip-172-26-6-180:~$


I can deal with the xdebug.log issue since it is probably permissions.  But how can I run my cron_job.php from the command line?
proof that an old dog can learn new tricks
Reply

#2
You still need to run it via index.php and provide route that should be executed (notice the space after .php):

Code:
php -f /opt/bitnami/apache2/htdocs/index.php /cron_job

All the CodeIgniter related code is included in index.php file, like setting up folders and loading core functionality.

I'm also 99% certain you can skip -f flag, I'm pretty sure I only have to do php index.php, but it could be different for different PHP versions.

If that method does not work (some servers have different settings), you can provide directory/controller/method with d= c= and m= attributes:

Code:
php -f /opt/bitnami/apache2/htdocs/index.php c=cron_job
Reply

#3
Thanks Pertti. I will get back to this.
proof that an old dog can learn new tricks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.