Thursday, July 5, 2012

CRON and other Linux command

-----------------linux command Start--------------------------------
chmod -R uog=rwx /var/www/html/htdocs/dev.link.in/filename.php give read wrie execute command to user,owner,group
tar xzvf filenae.tar extract file
tar czvf newfile.tar existingfile.php compress the file
cd / press enter to go to back direcotory
pwd present working direcory
ls -l list of all files and folders in current directory
chown root /var/www/html/dev.link.in/cronfile.php change the owner of the file

made a cron file

In the crontab file, there are six fields for each entry, each field separated by spaces or tabs.

* The first five fields specify when the command will be run.
* The sixth field is the command itself.

Minute - 0-59.
Hour - 0-23 24-hour format.
Day - 1-31 Day of the month.
Month - 1-12 Month of the year.
Weekday - 0-6 Day of the week. 0 refers to Sunday.


crontab -e
press i
add cron comand
* * * * * /usr/bin/php /var/www/html/dev.link.in/cronfile.php it wiil execute the command in every miniute
*/2 * * * * /usr/bin/php /var/www/html/dev.link.in/cronfile.php it wiil execute the command in every 2 miniute
*/5 * * * * /usr/bin/php /var/www/html/dev.link.in/cronfile.php it wiil execute the command in every 5 miniute

This crontab entry would run the command every 15 and 30 minutes after every hour, during the month of May:

15,30 * * 5 * /usr/bin/command

To run a backup script on just Sundays, Mondays, and Tuesdays at 2:12 AM, the entry would be:

12 2 * * 0-2 sh /root/backup.sh

To run a script at 12 minutes after every 3rd hour of every day, the entry would look like this:

12 */3 * * * sh /root/script.sh


press Esc then :wq press enter
you will exit from the vi editor
then show all cron commands
crontab -l

tail -f var/log/cron to see all cron file excution
php -f /var/www/html/dev.link.in/cronfile.php php file execution command (debug the error)
ctral z exit from executing commands


-----------------linux command End----------------------------------