HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Technical (http://www.howtoforge.com/forums/forumdisplay.php?f=8)
-   -   crontab -e syntax errors (http://www.howtoforge.com/forums/showthread.php?t=61988)

Frankly3D 27th May 2013 11:39

crontab -e syntax errors
 
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,

monkfish 29th May 2013 01:32

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!

Frankly3D 29th May 2013 11:37

Quote:

Originally Posted by monkfish (Post 297852)
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...


This works:

Code:

repoquery --queryformat %{name} --installed -a > /lists/64/"$(hostname -s).list"

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
Quote:

Originally Posted by monkfish (Post 297852)
How often you want to run this? You could of course put your script into /etc/cron.daily and be done with it!

If I get it working I would, any gotchas for cron.hourly

monkfish 29th May 2013 11:47

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.

Frankly3D 29th May 2013 12:17

Quote:

Originally Posted by monkfish (Post 297866)
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.

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.


All times are GMT +2. The time now is 22:49.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.