Go Down

Topic: problems with crontabs folder (Read 2475 times) previous topic - next topic

70agiuseppe

Hi!
I have a python script I'd like  it work  forever.
I assume I need to edit /etc/crontabs
but it appears empty.
I think I have to include this sentence:
@reboot python /mnt/sda1/Script/scriptUno.py
but to save it which extension can I give?
(.txt or .py ...)

thanks

noblepepper

Openwrt uses the busybox version of cron which doesn't support @reboot.

You can accomplish the same thing by modifying /etc/rc.local.

70agiuseppe

Thank you so much for the help


I consider to change rc.local in this way:
Code: [Select]
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.


/usr/bin/python2.7   /mnt/sda1/Script/scriptUno.py

wifi-live-or-reset
exit 0

check if I'm wrong please

noblepepper

If executing
Code: [Select]
/usr/bin/python2.7   /mnt/sda1/Script/scriptUno.py from the Linino command line does what you want to happen on every reboot this is correct.

You probably don't need the /usr/bin but it doesn't hurt either.

70agiuseppe

unfortunately  after reboot  not working!
with or without /usr/bin.

there may be problems with permissions? (chmod of scriptUno.py)

noblepepper

As long as you put your command before the exit 0, you probably have a problem with your script. It should check for conditions it needs to run such as the network being up. There isn't much else to go wrong.

For example this rc.local will create a file everytime the Yun powers up:
Code: [Select]
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

touch /mnt/sd/I_Ran         
wifi-live-or-reset
exit 0

70agiuseppe


you probably have a problem with your script.

Hi
I don't think so, the script does not have  problems.
because if I call it from putty  by:
Code: [Select]
/usr/bin/python2.7   /mnt/sda1/Script/scriptUno.py
it works perfectly!
have rc.local    root appropriate permission?

noblepepper

Yes, rc.local runs with root permissions, if you tried the example I gave the file the command created has root as owner and group.

There just isn't much that can go wrong. What assumptions does your command make? Are they valid as soon as boot is complete? i.e. is /mnt/sda1 mounted yet?

try this:
Code: [Select]
sleep 90;/usr/bin/python2.7   /mnt/sda1/Script/scriptUno.py
90 seconds should be plenty for all the start up services to have completed their work, if the script runs fine like that you can either accept a delay or have your script check for whatever it needs before it proceeds.

or this:
Code: [Select]
/usr/bin/python2.7   /mnt/sda1/Script/scriptUno.py 2>/root/err
then the file /root/err will have whatever errors occurred when the command was executed. You may want to try this command from a command prompt first, I'm not much of a Pythonner, if there is no error the file will be created but will be empty.


70agiuseppe

HI!
browsing and googling I found another example:

Code: [Select]
(sleep 90;python /mnt/sda1/Script/scriptTre.py)&

:) finally it seems to work! :)

please I would like to know what it means:   &   symbol?

thanks


70agiuseppe

anyway at last now it works!

many, many thanks for your help


P.S. Karma: +1

Go Up