Interpret if link is running from browser or cronjob

Asked

Viewed 77 times

0

I have a working cronjob but practically the link(PHP code) this public because for cronjob to work the authentication check system is disabled. So I’d like to know some way that this link do not get published by the browser, and only cronjob makes it work without authentication.

  • Could you add how is cronjob? Are you by any chance using Curl? If not, just remove the file from the "public_html" folder, for example, and move to the previous folder, this will be enough to hide the file from the public and still be able to call the file.

1 answer

2


Hello!

Instead of using the page server engine, use the interpreter’s CLI mode. For example in php you can type in the command line "php-cli /hosts/dominioexemplo.com.br/www/pagename.php" and it will return the output in bash. Just use that line in cron. Research CLI options such as verbosity and timeout to improve performance, and how to use returns. ;) PHP, Perl, Python -> All work on the command line.

Ach what it is that you need: https://www.a2hosting.com/kb/developer-corner/php/run-php-scripts-from-cron-jobs

I hope I’ve helped.

Hug!

  • Actually by the command line and even the best option, but as my hosting is windows I contacted the support of the hosting and claimed that can only be accessed the command line by the 'Putty', but I have had trouble setting it up and unsuccessfully so far my only option was to turn to the cronjob of the host control panel in this way. You know somehow I can access the command line?

  • Hello Luciano, It depends on the hosting service, and the panel’s own resources, this can occur. What hosting manager do you offer? OTHER OPTION: Use an encrypted key to add to CRON’s querystring, so you validate on the page, and even if it were public, you wouldn’t have a problem. To enforce, use directory restrictions on hosting for only the server’s ip access. ;) Let me know. Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.