uthpala pahalavithana
uthpala pahalavithana

Reputation: 69

Perl script running correctly, but as a crontab it does not work

I have a Perl script which inserts values in to a Mysql DB. Within the same script, I check a condition, and if successful, go to the asterisk CLI and run the originate command. When I run it in the terminal it's working properly. When I set it as a crontab, it will update the DB but the originate command is not working. I am new to Perl, please help me to solve this. Thanks in advance.

Perl script:

if($temperature > 85){
    print `asterisk -rx "originate Dongle/dongle0/0123456789 extension 400\@out"`;
}

Crontab:

*/1 * * * *   /home/test/bin/insert_mysql.pl

Upvotes: 3

Views: 589

Answers (1)

Galimov Albert
Galimov Albert

Reputation: 7357

Cron have different environment: he dont have PATH environment variable, so you must always use full path to commands; And, current directory is generally undefined, so when opening files must be careful; Also, it does not have locale settings but i think its not your case.

So you must give full path to asterisk and to file Dongle/dongle0/0123456789 (if it is file)

Upvotes: 6

Related Questions