79583728

Date: 2025-04-20 20:31:21
Score: 0.5
Natty:
Report link

My experience: be careful with ~ (tilde) in paths if you configure cron as root but work as another user.

I have root and USERNAME users and I want to backup things via a small script and save result to the Dropbox folder.

Here is content of crontab: backup.sh | gzip --best > ~/Dropbox/backup/backup.sql.gz

When I run the script as USERNAME everything is OK, script creates file at /home/USERNAME/Dropbox/backup/backup.sql.gz (pay attention to /home/USERNAME/)

But when I configured cron as root and the script is launched by cron it tries to create file at /root/Dropbox/backup/backup.sql.gz (pay attention to /root/) and it fails with the error cannot create /root/Dropbox/backup/backup.sql.gz: Directory nonexistent because there is no /root/Dropbox/backup folder.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: elebur