Dennis:

Thanks for this, I had to increase the hold off to 60 seconds but that’s fine 
for my purposes.  

I discovered that sudo systemctl status cron gives good output for debugging.

While troubleshooting, I made my script executable with chmod 777 autotest.py 
although I’m not certain this was necessary.

-Steve



> On Apr 16, 2021, at 3:28 PM, Dennis Lee Bieber <[email protected]> 
> wrote:
> 
> On Fri, 16 Apr 2021 09:01:33 -0700 (PDT), in
> gmane.comp.hardware.beagleboard.user
> "[email protected]"
> <[email protected]> wrote:
> 
>> I want my autorun python script to write information into a text file. 
>> This works fine when the python file is run from the Cloud9 interface, but 
>> does not run properly when the beagleboard restarted.  
>> 
>> The command that is failing is:
>> 
>> with open("/home/debian/logs/testlog.txt",'a',encoding = 'utf-8') as f:
>>  f.write("bbb autorun test\n")
>> 
>> I am running Buster IoT Image 2020-04-06 on a beagle board black.
>> 
>> I have tried using chmod 666, chmod 755 etc, on the target file and 
>> enclosing directory with no success.
>> 
>> I see a number of older threads about using chron, but these don't seem 
>> applicable in light of having autorun.
>> 
>> Any idea what is preventing this script from writing to a file when it is 
>> autorun?  Is this a permissions issue and how would I change that?
> 
>       I have no idea what systemd does when starting Cloud9 and processing
> its "autorun" directory...
> 
>       Personally, I would move your file /out of/ Cloud9 into some location
> in your home directory...
> 
> {in Cloud9}
> debian@beaglebone:/var/lib/cloud9$ mv autorun/autotest.py ~
> 
> ... and then add it to that user's crontab...
> 
> {rest is all via SSH using PuTTY}
> debian@beaglebone:~$ crontab -e
> no crontab for debian - using an empty one
> 
> Select an editor.  To change later, run 'select-editor'.
>  1. /usr/bin/vim.nox
>  2. /bin/nano        <---- easiest
>  3. /usr/bin/vim.basic
>  4. /usr/bin/vim.tiny
>  5. /bin/nano-tiny
> 
> Choose 1-5 [2]: 3
> crontab: installing new crontab
> 
> {the vim session is not shown} 
> 
>       Locating the actual crontab file...
> 
> debian@beaglebone:~$ sudo cat /var/spool/cron/crontabs/debian
> # DO NOT EDIT THIS FILE - edit the master and reinstall.
> # (/tmp/crontab.Wesos5/crontab installed on Fri Apr 16 15:00:39 2021)
> # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
> # Edit this file to introduce tasks to be run by cron.
> #
> # Each task to run has to be defined through a single line
> # indicating with different fields when the task will be run
> # and what command to run for the task
> #
> # To define the time you can provide concrete values for
> # minute (m), hour (h), day of month (dom), month (mon),
> # and day of week (dow) or use '*' in these fields (for 'any').
> #
> # Notice that tasks will be started based on the cron's system
> # daemon's notion of time and timezones.
> #
> # Output of the crontab jobs (including errors) is sent through
> # email to the user the crontab file belongs to (unless redirected).
> #
> # For example, you can run a backup of all your user accounts
> # at 5 a.m every week with:
> # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
> #
> # For more information see the manual pages of crontab(5) and cron(8)
> #
> # m h  dom mon dow   command
> @reboot sleep 30 && /home/debian/autotest.py
>> /home/debian/logs/unexpected.log  2>&1
> 
> debian@beaglebone:~$
>       Note: the crontab operation wrapped, the redirection is part of the
> @reboot line.
> 
>       I found I had to put in the 30 second delay to allow the system time to
> set up the GPIOs, without the job failed on 
> 
> GPIO.setup(relay3, GPIO.OUT)
> 
> with a missing file or permission error.
> 
>       I ended on 30 seconds as that is where dmesg had a major break...
> 
> [   25.949286] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
> [   26.184613] IPv6: ADDRCONF(NETDEV_UP): usb1: link is not ready
> [   66.991145] remoteproc remoteproc0: wkup_m3 is available
> [   67.376203] remoteproc remoteproc0: powering up wkup_m3
> 
> 
> 
> -- 
> Dennis L Bieber
> 
> -- 
> For more options, visit http://beagleboard.org/discuss
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beagleboard/k4mj7g99ck3j9l01upctmbtuj500b3afoh%404ax.com.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/4BBF76CA-8C38-49C3-AA29-9F246D75C062%40gmail.com.

Reply via email to