phprockers-logo

Cron Job in ubuntu

Cron Job in PHP
============
If we put the file in cron, It will run automatically by setting the time limit. Using time limit we have run the file every min/hour/day/month etc.

dckap1@dckap-desktop:~$ sudo su

[sudo] password for dckap1: **************
root@dckap-desktop:/home/dckap1# crontab -e

If you are using the cron in first time, First you should select the editor. It(crontab -e) will show five editor. Then you have to select the editor. Here nano editor is very useful in this, so you should select the nano editor.



How to select the nano editor

=====================

sudo /usr/bin/select-editor
Put this coding in command prompt, It will show more editor like...


1 /usr/bin/vim
2 /bin/ed
3 /bin/nano
4 /usr/bin/vim.basic
5 /usr/bin/vim.tiny

Here you have to select nano editor, ie, Number 3. After select the editor, It will go to cron file.


/10 * * * * /usr/bin/wget -q http://localhost/cron_test/test.php


After that save the file using command (ctl+x).


This page will be calling every 10 minutes automatically.


How to remove the cron job

====================
crontab -r

this command can be used for removing the cron job from the server.


How to list the cron job

=================
crontab -l

this command can be used for listing all the cron jobs running in current server.


How to edit the cron job

=================
crontab -e

this command can be used for editting the cronjob in our server.

0 comments:

Post a Comment