Cron job on Ubuntu for php

前端 未结 2 683
执念已碎
执念已碎 2020-12-15 01:24

I\'m using Ubuntu on the server and I\'m using Putty to access. I want to create cronjobs for my php site. How can I do this?

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 02:06

    I'm asssuming you want to backup your PHP site? Edit the crontab using:

    crontab -e
    

    This will start up an instance of vi in which you can edit the crontab, press i for insert mode. You then need to put in the information for when the cron entry will run and the command to run at that time, e.g.:

    30 10 * * * tar -zcvf ./myphpsite.tar.gz /var/www/phpsite
    

    So the command above will tar gzip your phpsite in /var/www/phpsite at 10:30pm every day. Exit and quit vi with :wq

    See this for further reference:

    http://www.adminschoice.com/docs/crontab.htm

提交回复
热议问题