如何以每隔一个小时建立一个以时间命名的文件夹

sh/bash/dash/ksh/zsh等Shell脚本
回复
525141335
帖子: 42
注册时间: 2009-03-14 0:18
来自: 广东技术师范学院

如何以每隔一个小时建立一个以时间命名的文件夹

#1

帖子 525141335 » 2010-05-14 18:43

如何以每隔一个小时建立一个以时间命名的文件夹?
刚学shell
希望各位大哥指点!
tyro
帖子: 111
注册时间: 2010-01-02 18:39

Re: 如何以每隔一个小时建立一个以时间命名的文件夹

#2

帖子 tyro » 2010-05-14 19:12

crontab?
My name's tyro and u can call me wowoto instead.
525141335
帖子: 42
注册时间: 2009-03-14 0:18
来自: 广东技术师范学院

Re: 如何以每隔一个小时建立一个以时间命名的文件夹

#3

帖子 525141335 » 2010-05-15 0:09

pocoyo 写了:
crontab?
:em11
具体如何写,能否详细,谢谢你们!
kamui0523
帖子: 547
注册时间: 2008-05-14 18:53
来自: 上海

Re: 如何以每隔一个小时建立一个以时间命名的文件夹

#4

帖子 kamui0523 » 2010-05-15 0:51

1.sudo /etc/init.d/cron start
2.crontab -e
3.select the editor which you familiar with
4.00 * * * * /bin/mkdir `date +%H:%M`
the directory name shows like as below
05:23

For print year,mouth and day,just relpace the setp 4 above with follow
00 * * * * /bin/mkdir `date +%y%m%d-%H:%M`
the directory name shows like as below
20100515-05:23
三年Linux使用经验,两年Ubuntu使用经验
提供各种企业解决方案
Ubuntu QQ群:66320976
Linux Blog
http://deephell.72pines.com
525141335
帖子: 42
注册时间: 2009-03-14 0:18
来自: 广东技术师范学院

Re: 如何以每隔一个小时建立一个以时间命名的文件夹

#5

帖子 525141335 » 2010-05-15 1:48

525141335 写了:
pocoyo 写了:
crontab?
:em11
具体如何写,能否详细,谢谢你们!
我知道了,是用crontab,具体如下:
1、新建一个crontab文档,如test,内容:* */1 * * * /home/hq/my.sh
2、在/home/hq/下建立一个shell ,my.sh,内容:mkdir /home/hq/`date +%Y-%m-%d_%H:%M:%S`
3、最后在终端执行:crontab /home/hq/test
这样就OK鸟!
应该没错吧,我先试一下
回复