Invoke Server Action from cron job

Hi,

I designed i server action which is invoked when a button is clicked in the front-end.
Is there a way to invoke from a cron job ?

Thx.

Hello @djeorges
Yes, server actions are just php files which are located in the dmxConnect/api folder, so you can run them using cron jobs.

Thank’s Teodor for your answer. It works but i have a problem with $_GET variable.
In my case i hace to pass the compid variable.

On my Cpanel Corn i try to pass this command:
image

But i get an error like this:
{"code":0,"file":"\/home\/cp1055927p05\/public_html\/dmxConnectLib\/lib\/core\/Request.php","line":30,"message":"Undefined index: REQUEST_METHOD","trace":"#0 \/home\/cp1055927p05\/public_html\/dmxConnectLib\/lib\/core\/Request.php(30): exception_error_handler(8, 'Undefined index...', '\/home\/cp1055927...', 30, Array)\n#1 \/home\/cp1055927p05\/public_html\/dmxConnectLib\/lib\/App.php(36): lib\\core\\Request->__construct(Object(lib\\App))\n#2 \/home\/cp1055927p05\/public_html\/dmxConnect\/api\/APIs\/DN\/GetBookings.php(5): lib\\App->__construct()\n#3 {main}"}

Hi @djeorges, I am not familiar with cron commands or how to pass a variable in a cron, but when I read over your post, the thought occurred to me that you could pass the variable in a where statement in your server action.

Another option is to use a curl command instead of php. I find this is easier as the syntax is the same as calling in a browser.

2 Likes

Many Thank’s all.
Finally, curl was the best solution.
And if it can help someone else, here is the cron command:
image

4 Likes