Welcome Guest, Not a member yet? Register   Sign In
running cronjob in Linux CLI
#1

(This post was last modified: 10-28-2018, 08:59 PM by richb201.)

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

(This post was last modified: 10-29-2018, 12:14 AM by Pertti.)

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




Theme © iAndrew 2016 - Forum software by © MyBB