crontab -e syntax errors

Discussion in 'Technical' started by Frankly3D, May 27, 2013.

  1. Frankly3D

    Frankly3D New Member

    In the terminal :# /bin/repoquery --queryformat %{name} --installed -a
    /lists/64/"$(hostname -s).list"

    works.


    Keep getting syntax errors running it as a cronjob :
    crontab -e
    /bin/repoquery --queryformat %{name} --installed -a
    /lists/64/"$(hostname -s).list"

    Have tried different syntax,' " around name, = to name,
    prepend /bin/bash, append exit
    Still errors,
     
  2. monkfish

    monkfish Member

    Think you might have to specify timings... there are 5 fields that go before the command set you want to run in cron, defined as minute,hour,day,month,day of week...

    eg

    run every minute
    Code:
    * * * * * /usr/local/ispconfig/server/server.sh
    run every 5 minutes:
    Code:
    */5 * * * * /usr/local/ispconfig/server/server.sh
    run at 5 minutes past the hour every hour:
    Code:
    5 * * * * /usr/local/ispconfig/server/server.sh
    Also is your script supposed to be piping output to file in /lists/64 - what shows up on my screen in your original post doesn't look quite right?

    This works:

    Code:
    repoquery --queryformat %{name} --installed -a > /lists/64/"$(hostname -s).list" 
    How often you want to run this? You could of course put your script into /etc/cron.daily and be done with it!
     
  3. Frankly3D

    Frankly3D New Member

    This is what I had, just dodgy c&p, along with the hourly run.

    Here's the error was getting in logwatch:
    Usage: repoquery [options]
    repoquery: error: --queryformat option requires an argument
    If I get it working I would, any gotchas for cron.hourly
     
  4. monkfish

    monkfish Member

    Put this in a script file, eg checkrepo.sh

    Code:
    #!/bin/sh
    repoquery --queryformat %{name} --installed -a > /lists/64/"$(hostname -s).list"
    
    Don't forget to chmod +x after you save it.

    Run it, does it produce the results? Seems to on mine. HTH.
     
  5. Frankly3D

    Frankly3D New Member

    Just tested it, as a cron hourly:
    # > /var/log/cron
    # run-parts /etc/cron.hourly
    # cat /var/log/cron
    May 29 10:11:33 frank01 run-parts(/etc/cron.hourly)[21072]: starting 0anacron
    May 29 10:11:33 frank01 run-parts(/etc/cron.hourly)[21081]: finished 0anacron
    May 29 10:11:33 frank01 run-parts(/etc/cron.hourly)[21072]: starting checkrepo.sh
    May 29 10:11:35 frank01 run-parts(/etc/cron.hourly)[21089]: finished checkrepo.sh
    May 29 10:11:35 frank01 run-parts(/etc/cron.hourly)[21072]: starting mcelog.cron
    May 29 10:11:35 frank01 run-parts(/etc/cron.hourly)[21095]: finished mcelog.cron

    It seems to run without hitch, thank you.
     

Share This Page