LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 12-18-2012, 01:29 AM   #1
leon.zcom
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.

autochannel.sh
/**********************************************/
#!/bin/sh
/sbin/iwconfig ath0 channel 0
/**********************************************/

autochannelschedule
/**********************************************/
*/1 * * * * /bin/sh /etc/autochannel.sh
/**********************************************/

in my main process, the code is
/**********************************************/
systemf("echo \' %s /bin/sh /etc/autochannel.sh \' > /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/autochannel.sh" .

Can someone tell me what's the problem? Thanks.
 
Old 01-13-2013, 11:11 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,369
Blog Entries: 54

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
Quote:
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/:
Code:
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:
Code:
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...


//NTLB
 
Old 01-14-2013, 12:11 AM   #3
leon.zcom
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.
 
  


Reply


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 11:58 AM
How to start KDE automaticlly without typing "startx" then "startkde" Jonescity Slackware 8 10-29-2004 09:32 PM
Automaticlly resizing pictures for website? fredgt Linux - Software 3 09-03-2004 02:45 AM
visit linux web from windows, the site couldn't execute "index.html" automaticlly Meditator Linux - Networking 3 03-20-2004 11:10 AM
How To Automaticlly Mount Network Shares? RedHatMN Linux - Networking 1 07-21-2003 04:57 PM


All times are GMT -5. The time now is 02:57 PM.

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