PDA

View Full Version : About cron job to automate scheduler tasks


Zeeboot
10-16-2007, 05:05 PM
I'm not sure why buy in FreeBSD6.2 my cron jobs just will not do my scheduled tasks.

What I've done to beat this is write a short bash script that will automate running the scheduler tasks.
------------------------------------------
#!/usr/local/bin/bash

X=1

while [ X=1 ]
do
lynx --source "http://localhost/cerb4/index.php/cron" &
sleep 90
done
------------------------------------------
I do not know why the cron job would not work and honestly I'm not that worried about it because this works fine.
Just throwing this out there if anyone else has issues with the cronjob.

jstanden
10-17-2007, 10:10 PM
How strange, but that should be helpful for anybody else in the same situation.

Does your cron not run any tasks (even non-Cerb4 ones)? How about something simple like:
* * * * * touch /tmp/pingfile

Every minute the modified timestamp on that file should change.

Edmund
11-28-2007, 04:50 AM
I've an almost similiar weird problem.

I am running FreeBSD 6.0 and my crontab well is running the tasks, nothing seems to be happening.

I have tried Zeeboot's suggestion as well but that did nothing as well. What am I missing?

Here's some more info:

Crontab:
*/2 * * * * /etc/cronscripts/cerb4trigger > /tmp/cerb4trigger.log

I have checked and verified that cerb4trigger.log does indeed have a timestamp update every 2 minutes.

Also, I made sure that my server's IP has been added under Configuration->General Settings->IP Security

Hildy
11-28-2007, 04:48 PM
what does your "cerb4trigger" script contain / do? Have you tried running through the steps of that script manually to see if there is any output?

Edmund
11-29-2007, 02:57 AM
what does your "cerb4trigger" script contain / do? Have you tried running through the steps of that script manually to see if there is any output?
It contains the bash script provided by Zeeboot in post #1 (which works beautifully at the command shell, thanks!). I have ran the script at the shell with no problems.

Any other thoughts?

jstanden
11-29-2007, 05:42 AM
My guess would just be permissions on the script for the user who's crontab you're editing.

Have you tried using 'su' to switch into that user and run the script at the shell? (Assuming it's not for your current login)

Worst case we can set up a FreeBSD6 virtual machine over here to test. It's probably something I should have going for Q/A anyway.

Thanks!

Edmund
11-29-2007, 08:59 AM
My guess would just be permissions on the script for the user who's crontab you're editing.

Have you tried using 'su' to switch into that user and run the script at the shell? (Assuming it's not for your current login)

Worst case we can set up a FreeBSD6 virtual machine over here to test. It's probably something I should have going for Q/A anyway.

Thanks!I did think of user permissions on the script and created the script using 'su' along with crontab. So crontab should be running under 'su' and as I mentioned earlier, I also tried running it at shell (as 'su') with no problems. Hence, I am really puzzled as to why this is happening. :(

kitchin
11-30-2007, 08:14 PM
Have you tried this?


export TERM="vt100"
lynx -dump "http://example.com/cerb4/index.php/cron"

My cron job was giving me an error about the terminal not allowing scrolling, and I Googled it and found that fix. When you run from the shell you don't get the error because you're on a terminal! And lynx seems to have no option just to dump super simple.

Also, "localhost" did not work for me so I used my domain name and waited for the error message about the IP and then allowed the IP in framework.config.php (or use configration / genneral settings / IP security).

Also I used -dump instead of -source because cron is emailing the output when I debug, and I don't want fricking user html in my email. What if it has a <script> tag? Using -dump pretty much formats it as text.

Also, why are you using a shell script to loop every 90 seconds AND cron to run every 1 minute? (AND note also, Cerberus keeps its own schedule, configuration / scheduler, which will effectively override if the time interval longer. Not to mention the 30 second auto-refresh on the page! But lynx will ignore that of course.)

Here again is the exact lynx error again in case anybody is searching on it:
Your terminal lacks the ability to clear the screen or position the cursor

jstanden
12-02-2007, 08:48 PM
Hey Kitchin!

You bring up good points.

I've never seen the terminal scrolling error, but that makes a lot of sense.

'localhost' is just an example in our URL, since we have no way of knowing the proper domain for each installation.

'lynx --dump' is fine. We use 'wget' and redirect the output.

Thanks for adding to the community knowledge pool. ;)

Edmund
12-03-2007, 06:50 AM
Have you tried this?


export TERM="vt100"
lynx -dump "http://example.com/cerb4/index.php/cron"

My cron job was giving me an error about the terminal not allowing scrolling, and I Googled it and found that fix. When you run from the shell you don't get the error because you're on a terminal! And lynx seems to have no option just to dump super simple.

Also, "localhost" did not work for me so I used my domain name and waited for the error message about the IP and then allowed the IP in framework.config.php (or use configration / genneral settings / IP security).

Also I used -dump instead of -source because cron is emailing the output when I debug, and I don't want fricking user html in my email. What if it has a <script> tag? Using -dump pretty much formats it as text.

Also, why are you using a shell script to loop every 90 seconds AND cron to run every 1 minute? (AND note also, Cerberus keeps its own schedule, configuration / scheduler, which will effectively override if the time interval longer. Not to mention the 30 second auto-refresh on the page! But lynx will ignore that of course.)

Here again is the exact lynx error again in case anybody is searching on it:
Your terminal lacks the ability to clear the screen or position the cursor
I just tried your code but that didn't help.

In any case, I am totally embarassed to say the least that you are so right about the silly mistake I made. I was not reading thoroughly and totally missed the fact that the shell script provided by Zeeboot was meant to replace the need to have the crontab do the job. I have fixed that and am now using the script exclusively to pop the emails.

Thanks!!