Posts

Showing posts with the label task scheduling

multiple cron job using same file

Hi guys, Today I am posting something about cron. 1 year back, I was getting some trouble in my project in scheduling cron. I had lots of task to be managed by cron, for that I was making multiple files. But after some research I managed those task by a single file. If your cron job accomplish similar tasks or requires the same libraries you will have to include the same files over and over to all your cronjobs ... or use this solution. Let say you have these cron jobs: 0 1 * * * /etc/lib/php -q /home/user/cron/cron1.php 15 1 * * * /etc/lib/php -q /home/user/cron/cron2.php 30 1 * * * /etc/lib/php -q /home/user/cron/cron3.php 0 2 * * * /etc/lib/php -q /home/user/cron/cron4.php And each of these cron jobs perform different tasks but use the same libraries like phpmailer, pdf creator, geoip, payment verification etc... The idea is simple, separate tasks or commands using parameters: 0 1 * * * /etc/lib/php -q /home/user/cron/cron1.php --task=task1 15 1 * * * /etc/lib...

schedule tasks on linux using crontab

If you've got a website that's heavy on your web server, you might want to run some processes like generating thumbnails or enriching data in the background. This way it can not interfere with the user interface. Linux has a great program for this called cron. It allows tasks to be automatically run in the background at regular intervals. You could also use it to automatically create backups, synchronize files, schedule updates, and much more. Welcome to the wonderful world of crontab. Crontab The crontab (cron derives from chronos , Greek for time; tab stands for table ) command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. To see what crontabs are currently running on your system, you can open a terminal and run: sudo crontab -l To edit the list of cronjobs you can run: sudo crontab -e This wil open a the default editor (could be vi or pico, if you want you can change the default editor) to let us manipu...