Koozali.org: home of the SME Server
Obsolete Releases => SME 7.x Contribs => Topic started by: JJSH on March 17, 2009, 04:32:44 PM
-
I've installed the Crontab Manager contrib. I am trying to get it to run the following command;
mysql -u myusername -pmypassword mydatabase < /home/e-smith/files/ibays/system/html/systemscripts/export.sql
The export.sql script generates a csv file. I know the above command works, as I can ssh in as root and copy / paste it from Crontab Manager, and hey presto, the required csv file is created in the required place, with no errors.
Try as I might, however, I can't get it to run from Crontab Manager. In desperation, I've set it to run every min, thus;
Minutes Every minute Hours Every hour Day Every day Month Day of the week User Command
* * * Every month Every day of week root (the above command)
By my thinking, it should run every min, but doesn't ~ in fact, whatever I try, I can't get it to run at all using Crontab Manager. I missing something obvious here, as the command is OK ~ can anyone help ~ I can't see anything obvious in the logs or system emails.
-
mmmmm, crontab -e -u root is empty. Is that correct?
-
The crontab for root probably is empty as the crontab manager doesn't run as root, it runs as admin, which is a psydenom... psyudenom...psyduenom... @#$% !!... alias for root.
Check the system log files - select the cron files and you should see it kicking off. I had trouble getting one to work and when I looked in there I found it wasn't quite doing what i expected, so i just created a manual crontab by running /usr/bin/crontab -e and entering the job that way. It now executes as I want.
-
JJSH.. IMO you are wasting your time :)
try to:
- create (if it does not exist) /etc/e-smith/templates-custom/etc/crontab dir
- then create a fragment into that dir like this:
*/5 * * * * root path_to_a_executable_shell_script_that_does_what_I_want
change the rule of execution as you like
into your script (in /etc or your /home or wherever you prefer) you put the command
then do
chmod +x your_script
- then expand the template
expand-template /etc/crontab
- and restart cron
service cron restart
it should work (at least works for me)
HTH
Ciao
Stefano
-
I'll give this a try. I have created and tested a script that does what I want, created the directory, but am a little lost at how I create a 'fragment'. Is this something I need to use 'touch' for? As you can see, I'm a bit of a command line newb. :grin:
-
I'll give this a try. I have created and tested a script that does what I want, created the directory, but am a little lost at how I create a 'fragment'. Is this something I need to use 'touch' for? As you can see, I'm a bit of a command line newb. :grin:
create a fragment = create a new file with pico, fill it with the desired content, save & close :-)
nothing more, nothing less
fragments are evaluated in alphabetical order.. ;-)
ciao
Stefano
-
Fantastic, I've got that working. Cheers for that. If I want to add other cron jobs, do I just add additional lines to that file, and the restart the crond service?
-
Fantastic, I've got that working. Cheers for that. If I want to add other cron jobs, do I just add additional lines to that file, and the restart the crond service?
add another fragment if it is for a different task, a line in the same fragment otherwise
Ciao
Stefano
-
Stefano has outlined a nice little simple way of setting up cron job. However he mentions using;
"service cron restart"
To restart the cron service.
I could not get this to work. I would not want to step on anyones fingers cause I might be wrong but the command that worked for me is
/sbin/service crond restart
(please note the d added to the end of the word cron)
Because you are restarting the daeman eg cronD . I'm not sure there is a service technically anyway, called cron, at least on my system.
I could be wrong.
Regards
-
/sbin/service crond restart
(please note the d added to the end of the word cron)
I could be wrong.
Regards
you are right.. my bad, was a typo :-)