CRON task not running!
-
@gertjan thanks for the replt.
sorry I dont understand.
So something like
#bash
logger "enable interface"
/sbin/ifconfig hn1 upand
#bash
logger "disable interface"
/sbin/ifconfig hn1 down.Was I even close to on the money HAHA.
Thanks
-
@deanfourie said in CRON task not running!:
#bash
No really.
Use any other shell script file to see what I mrean.
Is bash installed ? As far as I know, no.#!/bin/sh
If bash is installed :
#!/usr/local/bin/bash
because bash would be here : /usr/local/bin/
I found logger, it's in in /usr/bin/
-
@gertjan Sorry man im a little basic when it comes to scripting.
#!/bin/sh
/sbin/ifconfig hn1 downwould take the interface down correct?
-
@deanfourie said in CRON task not running!:
would take the interface down correct?
Yes.
A command typed on the command line, can also be used in a script file **.When I created a text file called /root/test like :
#!/bin/sh /usr/bin/logger "Disable interface" /sbin/ifconfig em0 down /usr/bin/logger "Enable interface" /sbin/ifconfig em0 up /usr/bin/logger "Done"
And I make it executable
chmod +x /root/test
Now I can
/root/test
In the system log, I saw :
and it broke my connection for a moment, as my WAN interface is em0 for me, it went down and up.
** edit : if the command is interactive, things get a bit more complicated.
-
@gertjan great thank you!
Then I need to execute the script from the Cron task? How can I call the script?
Thanks again appreciate your help
-
@deanfourie There is a cron package to manage cron jobs. As I recall if you manually add cron jobs, they are lost on reboot.
-
@steveits Yup, CRON package is installed.
Only thing I need to get right is to execute the script from the Cron job.
-
On the main cron page, you have 2 buttons :
How cron works, what you have to enter as the "time" needs some reading.
Any "FreeBSD cron man page" will do here. -
@gertjan Turn out this morning at 11 AM when I was away the interface went down.
Turns out I was using 12hour time format not 24hour.
FFS
So, after all that the CRONs do work.
-
@deanfourie said in CRON task not running!:
Turns out I was using 12hour time format not 24hour.
Yes, a day has 24 hours.
-
@gertjan Thanks for that
Thanks for your help!