How to check crontab input?

I have an entry in my crontab that looks like this:

0 3 * * * pg_dump mydb | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz

That the script works fine when I run it from the shell, but it doesn't seem to work every night. I assume that something is wrong with permissions, maybe crontab is working under a different user or something like that. How can I debug this? I am a public hosting environment (WebFaction).

+3
source share
4 answers

You need to avoid the "%" characters in backslash crontab entries - see the crontab (5) man page. I had exactly the same problem.

For instance:

0 7 * * * mysqldump usblog | bzip2 -c > usblog.$(date --utc +\%Y-\%m-\%dT\%H-\%M-\%SZ).sql.bz2

cron-? "MAILTO=you@example.com" crontab?

PATH crontab, pg_dump gzip ( "type pg_dump", , , crontab /bin /usr/bin )

+8

crontab. , /usr/bin/gzip. pg_dump date.

+2

, , ? ?

, crontab , .

- , , crontab. .

* * * * * touch /tmp/foo

, .

+2
source

If this is something like / etc / crontab, make sure the user is turned on:

0 3 * * * <user_goes_here> pg_dump mydb | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz
+1
source

Source: https://habr.com/ru/post/1749288/


All Articles