Answer the question
In order to leave comments, you need to log in
How to specify encoding for cron task?
Colleagues, hello everyone!
I recently encountered such a problem. When running a PHP script through a browser, the Cyrillic-to-Latin transliteration function works, but when the task is delivered to cron, it does not.
Let me explain in more detail:
There is a script that loads information to the products already created on the site. The comparison goes through the symbolic code. That is, the script takes the base from which we parse the data, transliterates the names from this base from Cyrillic to Latin, creating a symbolic code (if the name is from Latin, accordingly, transliteration does not occur). Next, the symbolic code is compared with those available on the site, and if there is a match, gluing takes place.
So, if we run such a script in a browser, everything is ok. If through crowns, then empty lines are returned to the character code, if the name is from Cyrillic.
In TimeWeb (where the project actually resides), I was told that "For the cron task, you can also specify the encoding and other PHP parameters. It makes sense to try to run the script by specifying the encoding." From here questions:
1) How to specify the encoding for the cron task? (not at all familiar with server programming, alas, I don’t understand this)
2) Well, TW support often gave me bad advice. Can someone express their expertise, maybe this problem is solved differently?
Thanks everyone in advance :)
Answer the question
In order to leave comments, you need to log in
How exactly is the cron script run? There are two ways how to do it:
1. using PHP CLI. Command like "/usr/bin/php70 /var/www/website/script.php"
2. using wget or curl. Type /usr/bin/curl " website.ru/script.php " 1> /dev/null 2> /dev/null
The second way is a complete imitation of running in a browser. This is the answer to the question "can such a problem be solved differently". Maybe.
The first method does not take into account the parameters that you have set in the Apache config and in the .htaccess file. Therefore, to launch in the first way, you need to set all of them explicitly in the script, as Arthur E. rightly noted .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question