Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use curly brackets in crontab?

Tags:

bash

cron

crontab

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?

like image 771
JeffDror Avatar asked Jun 30 '14 11:06

JeffDror


People also ask

Can you use {} in Python?

In languages like C curly braces ( {} ) are used to create program blocks used in flow control. In Python, curly braces are used to define a data structure called a dictionary (a key/value mapping), while white space indentation is used to define program blocks.

What does curly brackets mean in shell script?

The end of the variable name is usually signified by a space or newline. But what if we don't want a space or newline after printing the variable value? The curly braces tell the shell interpreter where the end of the variable name is.

What does curly braces mean in jquery?

Basically the curly braces {} are the another way for creating objects in javascript. This is equivalent to the "new Object()" syntax. Follow this answer to receive notifications.


1 Answers

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
like image 105
ach Avatar answered Sep 22 '22 03:09

ach