5

I was recently running a cron job using crontab -e and I found some strange behaviour. The following command doesn't work:

 * * * * * cp /home/username/{*txt,*pdf} /home/username/test/

but the following does

 * * * * * cp /home/username/*txt /home/username/test/

while both commands work in bash.

Why am I not able to use curly brackets in cron?

1 Answer 1

9

I suppose cron uses the sh shell to run your commands by default. sh does not support curly-brace wildcards.

IIRC, you can add to your crontab the following line:

SHELL=/bin/bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.