Bug resolved. When the script is launched from a cron it didn't work.