Search code examples
linuxbashcron

GZIP not running with crontab


I'm creating a crontab to run the scriptA.sh everyday at midnight

0 0 * * * . /config/scripts/scriptA.sh 2>&1

The scriptA.sh has the following configuration:

 /bin/gzip /logs_backup -q *;

When I execute the script, outside of crontab, the script runs perfectly, compressing all the files inside of logs_backup folder. However when the scriptA.sh is being called by crontab, it doesen't works.

I'm using the right path for gzip.

# which gzip
/bin/gzip

How I can put this script to works with crontab?

Looking for your comments and support.


Solution

  • Change this line

    /bin/gzip /logs_backup -q *;
    

    with this

    /bin/gzip /logs_backup -q /backup/directory/*;
    

    replacing with your real backup directory