So, i've added some codes in order to show somewhat like debug-log at existing program's code.
printf("wan port is down.");
I'm using UART to see and control the OpenWRT, and i can't see any messages shown at my console.
if i manually type the command to execute that program, i can see it.
also if i add
& at the end, i still can see it.
in order to type some commands while that program is running, i should be typing with
this program is executed by the cron, just after booting.
inside cron file, i can see
/usr/sbin/[program] & to run this program.
note that this program is 24/7 alive while my router is powered on.
there are no other files or programs that executes this program.
the only thing that runs this program is cron, and this uses
/usr/sbin/[program] & to run it.
How come i cannot see any messages at my console?
and how come i can see the message when i manually type
/usr/sbin/[program] & command?
i also tried changing my codes to
system("echo wan port is down.");
instead if using
printf. Same result when i was using
what can i do?
cron job is just run with
ash, so it's like typing it into
logger perhaps since it would run in it's own thread?
So you mean i need to use
logger instead of using
i'll try like this.
system("logger -s wan port is down");
thanks for the help
not working. i still need to manually type the command to execute this program to show at my console.
If you are running a
cronjob, it won't show anything on the console. The console is it's own terminal space. The exception to this would be kernel messages, i believe. If your script toggled the ethernet devices, you'll see the Ethernet control messages
For an automated
cronjob you should use
logger to send whatever it is you are trying to see to the system logs. If you are trying to debug, typing it into the console will give you the output, allowing you to perfect your syntax (although for mullti-line items, consider a
bash script and just call the script via
So, you are saying...
In order to get my program's log which is executed by
cron, i need to add
system("logger -s messages");
at the code, and i need to check the log file, right?
i searched this and i figured out that those logs are located at
i cannot find it. my var is a symlink to tmp directory. So i searched at
tmp/log/, but i cannot see anything.
can you tell me where those logs will be saved?
So i need to manually set the path where my logs will be saved.
Thanks a lot!!!
if i start this program not from
cron, but from
init.d, still printf or echo will not show a message to my console?
I guess it won't, hope i can check this by myself, but i cannot check my router now.
Actual purpose of this
echo is not for logging. it's just to indicate developers to know easily the port is down or up while we are looking at the console. so we don't have to physically look at the router.
Ok, now that I know you are trying to log Interface changes, have you looked at
Also, Ethernet Interface changes will show up in
dmesg (and therefor, you should see it on the console):
[ 55.530104] br-lan: port 1(eth1) entered blocking state
[ 55.535353] br-lan: port 1(eth1) entered disabled state
[ 55.540852] device eth1 entered promiscuous mode
[ 55.558625] br-lan: port 2(eth2) entered blocking state
[ 55.563890] br-lan: port 2(eth2) entered disabled state
[ 55.569406] device eth2 entered promiscuous mode
[ 55.574131] br-lan: port 2(eth2) entered blocking state
[ 55.579404] br-lan: port 2(eth2) entered forwarding state
[ 55.584938] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[ 55.625879] eth0: 1000 Mbps Full duplex, port 0, queue 0
[ 55.631576] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 56.607746] br-lan: port 2(eth2) entered disabled state
here is the way how i changed my code.
system(echo test_message > /dev/console);
Therefore, i can see the test_message at my console.
Still, thanks a lot for the help guys. I learned a lot from that.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.