1
hustlzp 2014-01-19 08:16:15 +08:00 via Android
赞,正需要这个!
|
2
scg16 2014-01-19 10:17:51 +08:00 via Android
小白vps装BT sync多次未成功~
|
3
scg16 2014-01-19 10:19:07 +08:00 via iPhone
求高手图文教程
|
4
funcman OP 试用没问题,请反馈。
图文全教程等回头写了,最近年底赶个项目爆忙。 |
5
funcman OP 有问题也反馈
|
6
sdzbzyc 2014-01-20 17:55:00 +08:00
|
7
sdzbzyc 2014-01-21 00:42:29 +08:00
/backup.sh: line 28: 7z: command not found
2) Click on "Create App", then select "Dropbox API app" 5) Enter the "App Name" that you prefer (e.g. MyUploader250872416932506) > App key is , App secret is and Access level is Full Dropbox. Looks ok? [y/n] # App key: # App secret: # Permission type, App folder or Full Dropbox [a/f]: > App key is , App secret is and Access level is Full Dropbox. Looks ok? [y/n] # App key: # App secret: # Permission type, App folder or Full Dropbox [a/f]: crontab日志一直就是提示第一次运行Dropbox-Uploader的状态..这个要改哪里呢 |
8
funcman OP @sdzbzyc 你没装7z啊。
Dropbox-Uploader那个,是不是因为你在手动上传时,操作上有什么失误,导致绑定配置没有被保存下来。 |
9
sdzbzyc 2014-01-21 10:18:51 +08:00
@funcman
7z装了,手动执行7z a 没有问题,不知道为什么会commad not found Dropbox-Uploader手动执行脚本可以,不知道为什么丢到crontab里不行了 环境变量不对吗? |
11
sdzbzyc 2014-01-21 13:54:33 +08:00
@funcman 是root用户
放在~/ 手动可以上传 > Uploading "/tmp/backup20140121/20140121.mydb.7z" to "/20140121.mydb.7z"... DONE > Uploading "/tmp/backup20140121/20140121.kcado.7z" to "/20140121.www.7z"... DONE |
12
funcman OP @sdzbzyc 我不太懂cron。查了下“command not found cron”,有帖子提到是因为cron用的shell是/bin/sh,改成/bin/bash就行了。
root的crontab文件中加入: SHELL=/bin/bash 你试试。 |
13
funcman OP 另外,我的系统是Ubuntu。
|
14
funcman OP 哦,所有的路径都用绝对路径。
你的三个脚本都放在/root下。 那么crontab里写 00 15 * * * root /root/autobackup.sh (这里是在UTC 15:00执行工作脚本) 上面那个回复的"SHELL=/bin/bash"别改了。 |
15
sdzbzyc 2014-01-21 14:34:34 +08:00
@funcman
我是centos 6 crontab里是 */5 * * * * root sh /root/autobackup.sh 脚本里面是 #!/bin/bash EPATH=$(cd `dirname $0`; pwd) DBPATH=/tmp/datebase`date +%Y%m%d` mkdir -p $DBPATH mysqldump -uroot -p643065 -hlocalhost wordpress > $DBPATH/mydb.sql /root/backup.sh -D"$DBPATH" -fmydb -d7 /root/backup.sh -D/home/wwwroot/www.kcado.com -fkcado -d7 rm -rf $DBPATH 问题是手动能上传成功呀,你看这个帖子/t/88061 他的问题跟我一样,在crontab里执行就执行第一次启动dropbox-uploader绑定appid的情况,没看明白怎么解决 |
16
funcman OP @sdzbzyc 系统差异还是有点的。
我不知道你是怎么给cron添加任务的。 我是直接编辑/etc/crontab的 完整内容: # cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 22 * * * * root cd / && run-parts --report /etc/cron.hourly 32 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 35 4 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 18 3 18 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 00 15 * * * root /root/backup_work.sh 中间那些任务是Ubuntu本来就有的可以无视 我怀疑是因为你的cron没有配置PATH CentOS也是用mail给你返回输出的么? 如果是,你po一下完整的信件内容。 |
18
funcman OP 还有,你是不是把你数据库密码暴露了……
|
19
sdzbzyc 2014-01-21 15:00:41 +08:00
是直接改/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 */3 * * * * root sh /root/auto.sh >> /root/mylog.log 2>&1 |
20
sdzbzyc 2014-01-21 15:10:30 +08:00 1
@funcman 额 一不小心给贴上来了
crontab输出的记录..不知道为什么7z not found,手动执行 7z a没有问题 /root/backup.sh: line 28: 7z: command not found This is the first time you run this script. 1) Open the following URL in your Browser, and log in using your account: https://www2.dropbox.com/developers/apps 2) Click on "Create App", then select "Dropbox API app" 3) Select "Files and datastores" 4) Now go on with the configuration, choosing the app permissions and access restrictions to your DropBox folder 5) Enter the "App Name" that you prefer (e.g. MyUploader306951655520556) Now, click on the "Create App" button. When your new App is successfully created, please type the App Key, App Secret and the Permission type shown in the confirmation page: # App key: # App secret: # Permission type, App folder or Full Dropbox [a/f]: > App key is , App secret is and Access level is Full Dropbox. Looks ok? [y/n] # App key: # App secret: # Permission type, App folder or Full Dropbox [a/f]: mail里面的也是说7z not found To: root@zhao Subject: Cron <root@zhao> /autobackup.sh Content-Type: text/plain; charset=ANSI_X3.4-1968 Auto-Submitted: auto-generated X-Cron-Env: <SHELL=/bin/bash> X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin> X-Cron-Env: <MAILTO=root> X-Cron-Env: <HOME=/> X-Cron-Env: <LOGNAME=root> X-Cron-Env: <USER=root> Status: RO /backup.sh: line 28: 7z: command not found /backup.sh: line 29: //dropbox_uploader.sh: No such file or directory |
21
funcman OP 你看一下CentOS中7z在那个bin目录下,cron的PATH有没有包含那个目录
另外,把crontab里的那个HOME从/改为/root 估计就能找到dropbox_uploader.sh了。 cron的环境变量真是个坑啊。试试吧,应该就是环境变量的问题。 |
23
funcman OP 回头得弄几个主流系统测试一下。
|
24
sdzbzyc 2014-01-21 21:12:04 +08:00
@funcman
下午突然就上不去网了...还以为我网络的问题 原来DNS被污染.. HOME改了后,dropbox_uploader.sh找到了 找了一下7z是在/usr/loacl/bin,PATH里加入后 还是.. /root/backup.sh: line 28: 7z: command not found > No such file or directory: /tmp/backup20140121/20140121.mydb.7z /root/backup.sh: line 28: 7z: command not found > No such file or directory: /tmp/backup20140121/20140121.kcado.7z 难道没找对吗,我是用locate 7z |
26
sdzbzyc 2014-01-21 22:06:55 +08:00
|
28
XXOO 2014-02-12 16:59:58 +08:00
加上。
|