문제

I'm using a script to add multiple cronjobs to users at the same time like so:

sed -e "s/\[\[USER\]\]/$user/g" $file > /home/deploy/cronjobScripts/tmp
crontab -u $user "/home/deploy/cronjobScripts/tmp"
crontab -u $user -l

$file points to a path with the template cronjob file.

But after crontab adds it to a user, it adds ^M to every line (carriage return in vim) which breaks the commands it has to execute.

Why does crontab do this and how can I prevent it?

도움이 되었습니까?

해결책

Arkascha was right after all, it seems that \r\n was present but vim did not show it.

When I used cat -vE /home/deploy/cronjobScripts/tmp it showed the \r after removing those with dos2unix the cronjobs worked perfectly

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top