Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-18-2012, 02:29 AM   #1
LQ Newbie
Registered: Apr 2008
Posts: 15

Rep: Reputation: 0
crand cannot automaticlly work problem

In mips enbedded system, i want to do someting periodically, but it cannot work. the code is as follow.
/sbin/iwconfig ath0 channel 0

*/1 * * * * /bin/sh /etc/

in my main process, the code is
systemf("echo \' %s /bin/sh /etc/ \' > /tmp/autochannelschedule"," */1 * * * *");
system("chmod 777 /tmp/autochannelschedule");
system("/usr/bin/crontab -d");
system("/usr/bin/crontab /tmp/autochannelschedule");
system("killall -9 crond && /usr/sbin/crond");

after system up, i use "crontab -l", the echo is "*/1 * * * * /bin/sh /etc/" .

Can someone tell me what's the problem? Thanks.
Old 01-13-2013, 12:11 PM   #2
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548
Originally Posted by leon.zcom View Post
Can someone tell me what's the problem?
No because we don't know the user you execute commands as (who's crontab this is) and we haven't seen cron log (error) entries or emailed output. Depending on your crond version 0) the cron daemon should pick up crontab changes automagically and a static task like yours may be 1) dumped in /etc/cron.d/:
echo '*/1 * * * * root /sbin/iwconfig ath0 channel 0' > /etc/cron.d/iwsetchan.cron
or 2) loaded from a temporary crontab (as mucking with /var/spool/cron/ files isn't SOP) like you already showed:
umask 027; /usr/bin/crontab -u root -l|grep -v iwconfig > /tmp/.crontab
echo '*/1 * * * * root /sbin/iwconfig ath0 channel 0' >> /tmp/.crontab
/usr/bin/crontab -u root /tmp/.crontab; rm -f /tmp/.crontab
The difference here is I specify a crontab user instead of assuming it, modify the existing crontab instead of replacing it and don't restart crond because it picks up crontab changes automagically. That leaves the question why on earth you would want to schedule this particular command to run every minute but then again it's your system...

Old 01-14-2013, 01:11 AM   #3
LQ Newbie
Registered: Apr 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks. I had fixed the problem.

But I didn't know the reason. I just modified the crontab file again and again, then test it.

Then It worked.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Suse linux 10.0 unable to boot with X-window, it resets automaticlly pp365 Linux - Hardware 1 08-25-2006 12:58 PM
How to start KDE automaticlly without typing "startx" then "startkde" Jonescity Slackware 8 10-29-2004 10:32 PM
Automaticlly resizing pictures for website? fredgt Linux - Software 3 09-03-2004 03:45 AM
visit linux web from windows, the site couldn't execute "index.html" automaticlly Meditator Linux - Networking 3 03-20-2004 12:10 PM
How To Automaticlly Mount Network Shares? RedHatMN Linux - Networking 1 07-21-2003 05:57 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration