程式狂想筆記

一個攻城師奮鬥史

0%

連續打指令&& 與;差別

Solved: cron question about multiple commands - Hewlett Packard Enterprise Community

1
2
3
4
5
6
7
8
9
10
11
12
13
14

Re: cron question about multiple commands
"echo ; ls" will execute both echo and ls, whatever is echo exit code.

"echo && ls" will execute ls only if echo exit code is 0.

Maybe you should do a script. Complex lines in crontab make it not clear and harder to maintain.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)

我有做個小實驗,簡單來講exit code;會傳回最後一個
但是&&會兩個看有沒有有沒有成功
Imgur