Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: PHP i GAMMU wywoływanie w cronie
Forum PHP.pl > Forum > PHP
xelexin
Cześć,
w crontabie mam linijkę
*/2 * * * * /usr/bin/php5 /home/uzytkownik/Pulpit/plik.php


Plik jezeli odpalam z konsoli dziala tak jak powinienen, natomiast jak jest w cronie to nie dziala, znacie może przyczynę?
rocktech.pl
Witam.

Pewnie php a nie php5 ..

Kod
*/2 * * * * /usr/bin/php /home/uzytkownik/Pulpit/plik.php


I przydałoby się dać prawa.

  1. chmod +X /home/uzytkownik/Pulpit/plik.php
xelexin
próbowałem, też nie działa
rocktech.pl
Zobacz gdzie masz interpreter. I prawa?

  1. whereis php
xelexin
  1. whereis php

wypluwa

  1. /usr/bin/php


żaden z tych pomysłów nie działa, jakieś inne?
redeemer
Strzelam w ciemno, że chodzi o względne scieżki w skrypcie.
Kod
*/2 * * * * cd /home/uzytkownik/Pulpit/; /usr/bin/php plik.php
xelexin
coś jakby ruszyło, wziałem skrypt w przeglądarce odpalilem i mam coś takiego:

Kod
echo tekst | gammu sendsms TEXT 6######## Error opening device, you don't have permissions. echo tekst | gammu sendsms TEXT 6######## Error opening device, you don't have permissions. echo tekst | gammu sendsms TEXT 6######## Error opening device, you don't have permissions. echo tekst | gammu sendsms TEXT 6######## Error opening device, you don't have permissions.
abort
1. dla 100% pewności: nie "php plik.php", tylko "php -f plik.php".
2. Jak program cokolwiek wywala na standard output albo standard error, to przydałoby się te strumienie przekierować:
Kod
a) php -f plik.php > stdout.txt 2>stderr.php
b) php -f plik.php > out+err.php 2>&1
c) php -f plik.php > /dev/null 2>stderr.php
d) php -f plik.php > stdout.php 2>/dev/null
e) php -f plik.php > /dev/null 2>&1


a - łapiesz strumienie do osobnych plików
b - łapiesz wszysto do jednego pliku
c - łapiesz tylko błędy
d - łapiesz wszystko OPRÓCZ błędów
e - wszelkie komunikaty masz w tzw. głębokim poważaniu

Domyślnie z reguły jest tak, że jak cokolwiek się pojawi na stdout albo na stderr, to leci (jedno i drugie) mailem do osoby, która to wywołała (do właściciela crona).

P.S.
Odpalasz dokładnie tak jak jest wpisane w crona, tzn. poprzez "/usr/bin/php5 /home/uzytkownik/Pulpit/plik.php" ?
xelexin
no to korzystając z a wywala mi takie coś:

Kod
echo test bazy | gammu sendsms TEXT 6######## gammu: Symbol `N6510Phone' has different size in shared object, consider re-linking gammu: Symbol `GSM_Countries' has different size in shared object, consider re-linking gammu: Symbol `GSM_Networks' has different size in shared object, consider re-linking gammu: Symbol `N9210Phone' has different size in shared object, consider re-linking gammu: Symbol `N7110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3650Phone' has different size in shared object, consider re-linking gammu: Symbol `N6110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3320Phone' has different size in shared object, consider re-linking Błąd: Version of installed libGammu.so (1.32.0) is different to version of Gammu (1.28.0) echo test bazy | gammu sendsms TEXT 6######## gammu: Symbol `N6510Phone' has different size in shared object, consider re-linking gammu: Symbol `GSM_Countries' has different size in shared object, consider re-linking gammu: Symbol `GSM_Networks' has different size in shared object, consider re-linking gammu: Symbol `N9210Phone' has different size in shared object, consider re-linking gammu: Symbol `N7110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3650Phone' has different size in shared object, consider re-linking gammu: Symbol `N6110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3320Phone' has different size in shared object, consider re-linking Błąd: Version of installed libGammu.so (1.32.0) is different to version of Gammu (1.28.0) echo test bazy | gammu sendsms TEXT 6######## gammu: Symbol `N6510Phone' has different size in shared object, consider re-linking gammu: Symbol `GSM_Countries' has different size in shared object, consider re-linking gammu: Symbol `GSM_Networks' has different size in shared object, consider re-linking gammu: Symbol `N9210Phone' has different size in shared object, consider re-linking gammu: Symbol `N7110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3650Phone' has different size in shared object, consider re-linking gammu: Symbol `N6110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3320Phone' has different size in shared object, consider re-linking Błąd: Version of installed libGammu.so (1.32.0) is different to version of Gammu (1.28.0) echo test bazy | gammu sendsms TEXT 6######## gammu: Symbol `N6510Phone' has different size in shared object, consider re-linking gammu: Symbol `GSM_Countries' has different size in shared object, consider re-linking gammu: Symbol `GSM_Networks' has different size in shared object, consider re-linking gammu: Symbol `N9210Phone' has different size in shared object, consider re-linking gammu: Symbol `N7110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3650Phone' has different size in shared object, consider re-linking gammu: Symbol `N6110Phone' has different size in shared object, consider re-linking gammu: Symbol `N3320Phone' has different size in shared object, consider re-linking Błąd: Version of installed libGammu.so (1.32.0) is different to version of Gammu (1.28.0)
abort
Masz błąd jak na tacy:
Kod
Błąd: Version of installed libGammu.so (1.32.0) is different to version of Gammu (1.28.0)

Masz inną wersję programu i bibliotek - przynajmniej tak to widzi php.
I to nie jest problem w PHP, ale w systemie. Musisz zunifikować wersje.
xelexin
Z samą unifikacją wersji jest niezły problem,

Ale co ciekawsze jak wklepie w konsole:
  1. echo test | gammu sendsms TEXT 6########


to wysyła normalnie sms.
abort
1. Zobacz, z jaką biblioteką jes linkowana binarka ('ldd gammu' w shellu).
2. Porównaj, co zawiera zmienna systemowa ENVIRONMENT (czyli w php tablica $_ENV) w php wywoływanym z CLI i z przeglądarki. W CLI możesz to także sprawdzić poprzez wydanie 'env' w shellu, w php wywoływanym z WWW powinno być to widoczne w phpinfo() (o ile ktoś nie zablokował)
3. Może trzeba pehapowi wywoływanemu z WWW w jakiś sposób dodać tę ścieżkę, w której jest biblioteka libGammu.so (w wersji 1.32.0)?

Nie miałem podobnych problemów, i cały czas nie umiem znaleźć odpowiedzi na pytanie, w jaki sposób w systemie znalazły się dwie biblioteki... Sam kompilowałeś?
xelexin
Więc tak jest rozwiązanie smile.gif

zamiast:

  1. echo test | gammu sendsms TEXT 6########


używamy

  1. echo test | /usr/local/bin/gammu sendsms TEXT 6########


Teraz już sms-y się wysyłają tylko jest inna ciekawa sprawa, że na niektóre komórki przychodzi dopiero po ich restarcie... Jakieś pomysły?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.