0

Linux 服务器每天会生成 4 个文件。这些文件必须每天通过直接连接到另一台 unix 中的服务器发送。

例如..ABC_1JUNE.txt、BCD_1JUNE.txt、CDE_1JUNE.txt、DEF_1JUNE.txt

如何在 shell 脚本中执行此操作...

4

2 回答 2

2

To schedule daily jobs on a UNIX-like system you can usually do that with cron. Create a script for that job in the /etc/cron.daily directory on the Linux server and have the cron daemon run it automatically. The script should simply contain the commands to be run. In this case it could look something like this:

#!/usr/bin/env bash

source=<local-dir>
destination=<remote-server>:<remote-dir>
suffix=1JUNE.txt

for file in {ABC,BCD,CDE,DEF}_${suffix}; do
    scp "$source/$file" "$destination"
done

This assumes there is a SSH daemon running on the remote server that you can connect to with scp. Replace the values for source and desination to match your real server name and file structures. The source here could also be a remote server.

于 2013-06-05T12:47:21.617 回答
1

将目标服务器共享文件夹挂载到源服务器文件夹中(反之亦然),然后使用 cp 命令将文件复制到那里。对于文件系统挂载: http: //linux.about.com/od/commands/l/blcmdl8_mount.htm 远程挂载

于 2013-06-05T11:53:17.353 回答