Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crontab Not Working Ubuntu

I am using crontab in ubuntu to send a csv to an email everyday, however it's not sending out. Why?

btw, i'm using laravel 4.2

UPDATED CRONTAB crontab:

* * * * * /usr/bin/php /var/www/html/.../app/controllers/CronTask.php > /var/www/html/.../public/cronoutput.txt

The functions of generating csv and send the csv to email are in CronTask.php. I wanna see the log of the cron so the log is cronoutput.txt.

What's the problem?

like image 683
hahahaha Avatar asked Oct 01 '15 01:10

hahahaha


1 Answers

Because i'm using laravel, so need to use laravel artisan command to run the crontab in ubuntu. i referred to this site to create command: https://sonnguyen.ws/laravel-4-and-crontab/

then put all the csv generation and email to fire function. it's done.

app/commands/FirstCommand.php

  1. php artisan command:make FirstCommand
  2. change protected $name = 'user:active';
  3. add generate csv and email in fire function. eg: echo "User activated"
  4. remove arguments in array in getArguments function

app/start/artisan.php

  1. Artisan::add(new FirstCommand);

in terminal:

crontab -e

command in crontab:

* * * * * /usr/bin/php /var/www/html/project/artisan user:active >> /var/www/html/project/public/cronoutput.txt
like image 59
hahahaha Avatar answered Nov 08 '22 20:11

hahahaha