将 BASH shell 会话记录到主机上的文件的最佳方法是什么?
首选输出格式等同于 PuTTY 的“可打印输出”日志设置,用户查看时包括输入和 ncurses 控制字符数据。
我想在 python 脚本中使用 rsync。我使用subprocess模块调用它,并使用存储在authorized_key远程机器上的文件中的公钥进行身份验证。
唯一的问题是,当我使用错误的远程用户名使用 rsync 时,会提示我输入密码,这显然会永远停止备份脚本。
rsync如果无法进行身份验证,我是否可以强制退出并显示错误,而不是提示输入密码?
乌迪
是否可以?我们可以完全控制我们的 DNS 服务器和实际指向的服务器。我们对当前获得的 DNS 查询数量感兴趣,因为我们想迁移到 Ultra DNS,但我们需要知道一个月内可能获得的查询数量。
这有可能弄清楚吗?我需要在跟踪开始前启动服务吗?还是使用shell来访问数据?
我想控制这样的 bash 脚本:
#!/bin/sh
USER1=_parsefromfile_
HOST1=_parsefromfile_
PW1=_parsefromfile_
USER2=_parsefromfile_
HOST2=_parsefromfile_
PW2=_parsefromfile_
imapsync \
--buffersize 8192000 --nosyncacls --subscribe --syncinternaldates --IgnoreSizeErrors \
--host1 $HOST1 --user1 $USER1 --password1 $PW1 --ssl1 --port1 993 --noauthmd5 \
--host2 $HOST2 --user2 $USER2 --password2 $PW2 --ssl2 --port2 993 --noauthmd5 --allowsizemismatch
Run Code Online (Sandbox Code Playgroud)
使用来自控制文件的参数,如下所示:
host1 user1 password1 host2 user2 password2
anotherhost1 anotheruser1 anotherpassword1 anotherhost2 anotheruser2 anotherpassword2
Run Code Online (Sandbox Code Playgroud)
其中每一行代表脚本的一次运行,其中提取了参数并制成变量。
这样做的最优雅的方式是什么?
拍
我最了解的编程语言是 Java。目前我必须编写相当多的“shell 脚本”来自动化我的服务器。有没有像“Java Shell”这样的东西,所以我可以用Java编写shell脚本?
这是我的 crontab 文件的内容:
0 0,6,12,18 * * * cd /var/www/app/current && backup perform --trigger db_backup --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp >> /var/www/app/current/log/cron.log 2>&1
0 3 * * * cd /var/www/app/current && RAILS_ENV=production bundle exec rake runs:populate --silent >> /var/www/app/current/log/cron.log 2>&1
59 23 * * * cd /var/www/app/current && RAILS_ENV=production bundle exec rake runs:log --silent >> /var/www/app/current/log/cron.log 2>&1
Run Code Online (Sandbox Code Playgroud)
如果我以 crontab 的所有者身份手动运行其中任何一个,它们工作正常,但该cron.log文件仅包含:
/bin/sh: bundle: not found
/bin/sh: backup: not found
/bin/sh: bundle: not found
Run Code Online (Sandbox Code Playgroud)
我尝试将每一个都包装在以下(默认情况下,我用来管理我的 cron 文件的 …
编辑:由于某种原因,我的帖子的一半被截断了,不知道发生了什么。我会尽快更新,并将在顶部发布它已更新。
编辑:我再次更新了帖子,对于不完整的问题很抱歉。
编辑(东部标准时间 10/10/2011 晚上 8:55):我像史蒂文建议的那样更新了 /srv/rhodecode/start.sh,但仍然不高兴。它继续像这样挂起:
[lpeabody@vcs rhodecode]$ sudo /etc/init.d/rhodecode-server start
Starting rhodecode-server:
Run Code Online (Sandbox Code Playgroud)
我已经更新了下面的脚本以显示更改。
我一生中从未编写过 shell 或 bash 脚本。我正在尝试在 CentOS 上安装 RhodeCode,并且有适用于 Debian 和 Gentoo 的初始化脚本,但不适用于 RedHat/CentOS,这对我来说很疯狂。所以我需要写一个,因为我们的服务器环境仅限于运行 CentOS 5。该项目的源代码可以在这里的Bitbucket找到。
这个想法是用 Celery 和 RabbitMQ 运行 RhodeCode。它都是用 Python 编写的,我使用 virtualenv 在它自己的单独虚拟容器中拥有环境。我在这里得到了 shell 脚本的想法。
我创建了一个名为 rhodecode 的系统用户,并创建了目录 /var/run/rhodecode 并且它归 rhodecode 所有。我还创建了生产.ini 所在的/var/www/rhodecode 以及/srv/rhodecode/start.sh,所有这些都归rhodecode 所有。
权限:
[lpeabody@vcs run]$ ll -a /var/run/rhodecode
total 12
drwxr-xr-x 2 rhodecode rhodecode 4096 Oct 10 15:57 .
drwxr-xr-x 21 root root 4096 …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个脚本,该脚本允许用户选择他需要对表格进行的操作。我想检查表是否存在。如果它存在,我将继续其他事情,否则我退出说表不存在。我怎么可能做到这一点。
我注意到一个进程在我的 linux 服务器上占用了全部 CPU,其中的 COMMAND 列top -c是-bash.
cat /proc/<pid>/cmdline也显示-bash。
前面的破折号是什么意思?
更多信息:我不知道它是否相关, /proc/<pid>/exe -> /bin/bash (deleted)
环境是Ubuntu Server 12.04
我想在服务器上创建一个用户,该用户只能通过 ssh 进入在日志文件上运行 tail -f 并在程序结束(ctrl+c)后关闭会话的 shell。
有没有办法实现这一目标?