Set-up cron job on Ubuntu server

How to set-up cron in Ubuntu server:

You need to follow the below steps to configure the crontab.

Step 1: Run the below command to open the crontab
sudo crontab -u ubuntu -e

 cronsetup1

Step 2: Will ask to choose the editor

 

cronsetup2

Step 3: Now we can add the cron file with path and set the execution time.

#SHELL=/bin/sh
#PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
#MAILTO=root

*/10 * * * * /usr/bin/php /var/www/prafulkr/cJobCRMCron.php > /var/www/logs/cronlogShadow.txt 2>&1
*/04 * * * * /usr/bin/php /var/www/prafulkr/latLongProcessCron.php > /var/www/logs/latLongProcessCronLog.txt 2>&1
*/21 * * * * /usr/bin/php /var/www/prafulkr/deltaImportCron2.php > /var/www/logs/cronlogproduction.txt 2>&1
*/25 * * * * /usr/bin/php /var/www/prafulkr/deltaImportCron2.php > /var/www/logs/deltaImportAppCronLog.txt 2>&1"

cronsetup3

Step 4save the file and then restart the apache server.

sudo /etc/init.d/apache2 restart

Now you have done setting up your cron job successfully on ubuntu server.

Note: 4 cron jab setted with execution time of 10 minutes, 4 minutes, 21 minutes and 25 minutes. Also creating a log for every cronjob and storing it in logs folder. You may need to put the exact path of the script as well as the path of the logs.

 

Posted in Linux | Tagged , , , , | Comments Off

Comments are closed.