sh创建文件夹

时间:2025-10-09 15:01:08编辑:小松

如何在linux系统中编辑一个脚本,可以自动运行另一个文件夹里的所有脚本?

你写进crontab计划任务就好了,具体操作,百度linux crontab
[root@localhost ~]# cat /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


编写shell脚本,实现移动一个文件

polly@nowthen:~/test$ cat mv.sh#!/bin/bashusage() { echo "`basename $0` filetomove targetlocation" exit 1}if [ $# -ne 2 ]; then usageelse if [ -e $1 -a -f $1 -o -e $1 -a -d $1 ]; then echo "$1 exist" temp=`basename $1` echo "file to mv: ${temp}" if [ -e ${temp} ]; then while [ -e ${temp} ] do echo "${temp} exists in current dir" sleep 1 done echo "${temp} removed, and copy begin" cp -r $1 $2 exit 0 else cp -r $1 $2 fififi程序没有检查目标文件夹是否存在,可以移动文件及文件夹


上一篇:勇者电视剧完整版42集

下一篇:没有了