1

how can I see if my backups is saved after the minute assigned? how can I test it if it's ok?

cron job

3
  • you've posted an illegible screenshot with what looks like it might be an ftp session in the background and a terminal in the fg with fuzzy, unreadable text of what may be a crontab loaded in nano. is it supposed to give useful information? It doesn't. Don't post images when text will do. especially don't post screenshot images of text. Images can't be searched, edited, copy-pasted or even viewed on screens with higher resolution than yours (or by sight-impaired users dependent on screen-reading software). Delete the image, then copy and paste the TEXT from your shell into the question.
    – cas
    Jun 29 '16 at 1:47
  • i'm on no gui to copy the text Jun 29 '16 at 1:55
  • can you translate that into english?
    – cas
    Jun 29 '16 at 2:06
2

You have a couple of options here:

  1. Check the modification date of the file to see if it's being updated:

ls -l /var/backups/your-file.sql

  1. If you haven't quite migrated over to systemd yet, cron should be logging to /var/log/syslog, in which case you can do something like this and check the timestamps:

cat /var/log/syslog | grep -i cron

  1. If you are on systemd though, you'll need to use this command:

sudo systemctl status cron

And look for something along the lines of this for your user:

Jun 28 17:44:01 openSUSE cron[1865]: pam_unix(crond:session): session opened for user billy by (uid=0)

Alternatively, you could put that command into a script that logs the outcome for you:

#!/bin/bash 

# It's good practice to include the full path to the executable when calling it in a script, especially from cron
DATE=/usr/bin/date
MYSQLDUMP=/usr/bin/mysqldump

# Run your backup command here
$MYSQLDUMP -u user -p password database > /var/backups/backup.sql

# Then check to make sure it executed successfully
if [[ $? -eq 0 ]]; then 
    echo "$DATE - Backup saved"
else
    echo "$DATE - Backup failed"
fi

Save that as a file called say db-backup.sh, give it execute permissions, and then set that as the cron job instead.Just remember to use the full path to the script since cron may have a different PATH than you do.

0

You can check for your logs, you can see if cron job executes:

Jun 24 12:42:01 serversuit CROND[24483]: (root) CMD (echo "hello" > /tmp/testfile)

Also you can send all output to some file:

/scripts/testscript.sh &> /logs/testscript.log

Take a look here for more examples of cron job troubleshooting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.