Start crontab

Hello,
here is my crontab command that is not executing

*/5 * * * * /usr/local/bin/purge_db.sh
// my script that crontab should run every 5 minutes
#!/bin/bash
mysql SERVER -pstaines < SQL1.txt
// the content of SQL1.txt
DELETE FROM LOG_FILE WHERE DATE < SUBDATE(NOW(), INTERVAL 1 DAY)
Configuration: Windows XP Firefox 3.0.6

22 answers

  1. Hello,

    Be careful because on some platforms like HP-UX it is not possible to use */n in the crontab.
    You then have to type out 5,10,15....

    Have a good day.
    1. Contributor
      hello
      the script runs without environment, .bashrc is not executed by cron
      put
      source ~/.bashrc
      at the beginning of the script
      1. It still doesn't work
        I added
        #!/.bashrc
        #!/bin/bash
        mysql SERVER -pstaines < SQL1.txt
        // the content of SQL1.txt
        DELETE FROM LOG_FILE WHERE DATE < SUBDATE(NOW(), INTERVAL 1 DAY)
        1. Contributor
          non, like this:

          #!/bin/bash
          source ~/.bashrc
          mysql SERVER -pstaines < SQL1.txt
          1. Here is the translation: ```html Here is my script and it still doesn't work, that is to say, nothing happens!!!
            #!/bin/bash
            source ~/.bashrc
            mysql SERVER -pstaines < SQL1.txt
            thank you ```
            1. Contributor
              Is cron running?
              ps -ef | grep cron
              Is the script executable?
              chmod u+x /usr/local/bin/purge_db.sh
              Is it running as root?
              1. when I run the command ps -ef | grep cron

                root 4536 1 0 Feb03 ? 00:00:00 /usr/sbin/cron
                root 8530 6953 0 16:16 pts/0 00:00:00 grep cron

                I am logged in as root
                1. yes, because when I run it manually without the crontab, it works.
                  1. Contributor
                    see what’s happening in a file
                    */5 * * * * /usr/local/bin/purge_db.sh > /tmp/log 2>&1
                    also check in /var/log
                    1. In my log I have:

                      apache2 auth.log.3.gz daemon.log.2.gz dist-upgrade dpkg.log kern.log.0 mail.info messages.3.gz mysql.log.4.gz syslog.0 udev
                      apparmor boot daemon.log.3.gz dmesg dpkg.log.1 kern.log.1.gz mail.log mysql mysql.log.5.gz syslog.1.gz user.log
                      apt btmp debug dmesg.0 dpkg.log.2.gz kern.log.2.gz mail.warn mysql.err mysql.log.6.gz syslog.2.gz wtmp
                      auth.log btmp.1 debug.0 dmesg.1.gz faillog kern.log.3.gz messages mysql.log mysql.log.7.gz syslog.3.gz wtmp.1
                      auth.log.0 daemon.log debug.1.gz dmesg.2.gz fsck lastlog messages.0 mysql.log.1.gz news syslog.4.gz
                      auth.log.1.gz daemon.log.0 debug.2.gz dmesg.3.gz installer lpr.log messages.1.gz mysql.log.2.gz pycentral.log syslog.5.gz
                      auth.log.2.gz daemon.log.1.gz debug.3.gz dmesg.4.gz kern.log mail.err messages.2.gz mysql.log.3.gz syslog syslog.6.gz
                      1. Contributor
                        The cron configuration varies depending on the systems. Use man cron to see how to create a log of jobs running by cron.
                        1. ok!
                          when I run cron -f I have
                          cron: can't lock /var/run/crond.pid, otherpid may be 4536: Resource temporarily unavailable

                          how do I make it active
                          1. I'm in a bad situation because it’s overwhelming me now
                            I don't understand anything anymore!!
                            1. When I go to /tmp and I type vim log, I get:

                              /usr/local/bin/purge_db.sh: line 3: SQL1.txt: No such file or directory
                              1. Contributor
                                When your script starts as root, it is in / so it cannot find the file /SQL1.txt.
                                • 1
                                • 2