-1

I used CentOS for Wordpress web server. I want backup media and SQL once per day, so I edit crontab as below:

[john@cent ~]$ crontab -e
TZ=Asia/Ho_Chi_Minh
15 3 * * * /bin/sh /home/john/deploy/job/backup-mysql.sh 2>&1 >> /home/john/deploy/job/log/backup-mysql.log
30 3 * * * /bin/sh /home/john/deploy/job/backup-media.sh 2>&1 >> /home/john/deploy/job/log/backup-media.log

I mean run these job once per day, but it really run twice:

[john@cent ~]$ cd deploy/mediadump/
[john@cent mediadump]$ ls
07-08-2015_03.30.01.uploads.tar.gz
07-08-2015_14.38.01.uploads.tar.gz
08-08-2015_03.30.01.uploads.tar.gz
08-08-2015_14.38.01.uploads.tar.gz
09-08-2015_03.30.01.uploads.tar.gz
09-08-2015_14.38.01.uploads.tar.gz

What did I wrong?

UPDATE The sqldump job run same with mediadump. I listed files, as @lain and @Paul suggested, check log file again, and I realize the root user run jobs at 14:38 for media and 14:36 for sql:

[root@cent datadump]# ls -l
-rw-r--r-- 1 john john 2391638 Th08  7 03:15 07-08-2015_03.15.01.sql
-rw-r--r-- 1 root  root  2437070 Th08  7 14:36 07-08-2015_14.36.01.sql
-rw-r--r-- 1 john john 2560015 Th08  8 03:15 08-08-2015_03.15.01.sql
-rw-r--r-- 1 root  root  2667435 Th08  8 14:36 08-08-2015_14.36.01.sql
-rw-r--r-- 1 john john 2618756 Th08  9 03:15 09-08-2015_03.15.01.sql
-rw-r--r-- 1 root  root  2928775 Th08  9 14:36 09-08-2015_14.36.01.sql

Ago, I tested crontab on root user by the way edit /etc/crontab. I forgot clear that file before switch to John for run needed job. I fix it ok. Thanks a lot @lain, @Paul Haldane.

5
  • 1
    look in /var/log/cron for relevant entries.
    – user9517
    Aug 9, 2015 at 17:18
  • @lain ok, but I don't see any strange things.
    – Davuz
    Aug 10, 2015 at 4:05
  • Based on what you've shown us I suspect that both jobs create tar files under mediadump. Is that not what you're expecting? Is the SQL file created correctly? (Assuming that should be in a different folder) Aug 10, 2015 at 6:27
  • Please show us the relevant log entries.
    – user9517
    Aug 10, 2015 at 6:54
  • Thanks you. I fixed it. I have 2 user run this job so the dump is twice.
    – Davuz
    Aug 11, 2015 at 3:34

1 Answer 1

3

It seems that you are running the same job as two different users. The log files should have been able to help you track that down. The timestamps on the dump files confirm multiple users.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .