---
title: "ubuntu下之crontab"
author: "labreeze"
date: "2012-09-27T20:22:25Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu-crontab"
draft: false
lastmod: "2020-05-23T01:26:54Z"
id: 1687626
url: "https://labreeze.iteye.com/blog/1687626"
---

**mysql备份**  
**先进入root**  
**编辑文件**  
**mysql\_bak.sh内容**  
**mysqldump -u root -p123456 test &gt; /home/fesco/scripts/$(date +%Y%m%d)-mysql-test.sql**  
**设定每分钟的备份**  
**crontab -e**     
*** * * * * /home/fesco/scripts/mysql\_bak.sh**  
**重启crontab**  
**/etc/init.d/cron  restart**

 

**定时关机**

**vim /etc/crontab**    
**30 5 * * * root init 6**

**重启crontab**  
**/etc/init.d/cron  restart**