This is my script,
#!/bin/bash suffix=$(date +%w) rm /home/myuser/backup/mongo-$suffix -rf mkdir /home/myuser/backup/mongo-$suffix mongodump -h$1 -u$2 -p$3 -dmydb -o/home/myuser/backup/mongo-$suffix
0 3 * * * /bin/bash /home/myuser/myproject/production/backup_mongo.sh localhost user1 pass1
When I run the script normally (executing the command above), the script works and the directory "mydb" gets created in /mongo-$suffix.
However, when I put this in crontab, /mongo-$suffix gets created but the "mydb" directory does not exist. There's nothing in /mongo-$suffix.