首先进入终端输入
$crontab -e
在文件中编辑以下内容
0 10,15 * * * tar -zcvf ~/pinyin.tar.gz ~/.cache/ibus/pinyin/*
#每天的10点和15点对用户词库进行备份
0 10,15 * * 1 tar -zcvf ~/CentOS_skills.tar.gz ~/CentOS_skills/*
#每周一的10点和15点对文件夹进行打包备份
0 10,15 * * * date >> bk.log
#每天的10点和15点执行date命令并输出到文件
然后保存退出
# cd /etc/init.d/
# ./crond restart
$ more /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
$crontab -e
在文件中编辑以下内容
0 10,15 * * * tar -zcvf ~/pinyin.tar.gz ~/.cache/ibus/pinyin/*
#每天的10点和15点对用户词库进行备份
0 10,15 * * 1 tar -zcvf ~/CentOS_skills.tar.gz ~/CentOS_skills/*
#每周一的10点和15点对文件夹进行打包备份
0 10,15 * * * date >> bk.log
#每天的10点和15点执行date命令并输出到文件
然后保存退出
# cd /etc/init.d/
# ./crond restart
$ more /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed