如何用 cron 做到这一点?
cp * ~/destination.0cp * ~/destination.1cp * ~/destination.0cp * ~/destination.1...等等。
任何帮助将不胜感激!
一个班轮:
0 0 * * * cp /path/to/* /path/to/destination.$(( $(date -d $(date +%F) +%s)/(3600*24) % 2))
Run Code Online (Sandbox Code Playgroud)
解释:
$(( $(date -d 0:00 +%s)/(3600*24) % 2))
Run Code Online (Sandbox Code Playgroud)
+%s今天的 0:00 ( -d 0:00)返回以秒 ( ) 为单位的时间戳。(3600*24)将返回 unix 纪元的天数。%2 将在 unix 纪元开始后的奇数天或偶数天返回 0 或 1。