Cronjob fatal error includes

I am trying to setup a cronjob but cannot get it to work because of the includes…

I have read that you can change from whick directory the cronjob is executed but my host told me the cd command is not available in directadmin (the server software).

Is there a different solution that you can think of to make cronjobs with includes work?

Do you have access to SSH on the host machine? You should be able to do this via shell access with sudo permissions.

Hi Dave,
Yes I found the ssh setting and enabled it.

Can you tell me more or point me to a tutorial or something?

This should help to get you on your way:

Plenty of guides on how to do this. Plus a fair few results in the Community search:

https://community.wappler.io/search?q=cron

Thanks Dave.
I am on windows. Does that work?

What is the server architecture you’re hosting on @_Jim?

I’m not familiar with Windows hosting at all unfortunately (we always opt for Linux)…

A quick search finds the following that may be of help:

Looking at Directadmin it only appears to be available on Linux:

https://docs.directadmin.com/getting-started/installation/overview.html

So that may answer my above question… In that case my original reply above, regarding cron jobs, should be what you need to check out.

Maybe something like this:

bash -c "cd /home/mydirectory && php cron.php"

By the way, DirectAdmin has a cronjob page, you don’t need to use SSH:

2 Likes

Just as a note of precaution be very careful what interval you set to run your cron jobs as too often could cause a dramatic repercussion for your servers performance, some hosts may disable your jobs from running if this is the case…

Thanks all for jumping in :slight_smile:

My hosting is not windows… It’s appache/mysql php…
My work computer is windows.

@Apple yes directadmin has cronjobs. But I cannot use the cd (change directory) command (I was told) so that’s why I ask for a different solution.

But if you think it is possible, I’d love to hear

Perhaps what the tech meant is you couldn't use "cd" in a cronjob. But I wrapped it inside the command "bash", so it should be good (neat trick I learned somehow)

Well the bash command did something. No more include errors.

New error: undefined index

{"code":0,"file":"\/home\/mynftees\/domains\/mynftees.nl\/public_html\/dmxConnectLib\/lib\/core\/Request.php","line":26,"message":"Undefined index: REQUEST_METHOD","trace":"#0 \/home\/mynftees\/domains\/mynftees.nl\/public_html\/dmxConnectLib\/lib\/core\/Request.php(26): exception_error_handler(8, 'Undefined index...', '\/home\/mynftees\/...', 26, Array)\n#1 \/home\/mynftees\/domains\/mynftees.nl\/public_html\/dmxConnectLib\/lib\/App.php(36): lib\\core\\Request->__construct(Object(lib\\App))\n#2 \/home\/mynftees\/domains\/mynftees.nl\/public_html\/dmxConnect\/api\/floor_loop.php(5): lib\\App->__construct()\n#3 {main}"}

Undefined index: REQUEST_METHOD

So, turns out you can't call this script directly. You have to use curl instead:

curl http://yourwebsite.com/cron.php

This is because $_SERVER['REQUEST_METHOD'] doesn't exist when called through the command line, so you have to call it through HTTP

curl is a command line tool to perform HTTP requests

1 Like

Thanks Apple

The curl method works great!
Maybe not as efficient but it works :smiley: