On Wednesday, April 10, 2013 7:46:42 PM UTC+2, someone wrote:
> Do you know how to solve this? Is it necessary to call another script, which logs to /tmp, just to ensure flushing the write cache?
>
>
> Thanks...
Uh, sorry - I just got a new idea and want to ask an additional question (besides the flush write cache-question above):
Currently, I have to setup power-on-time using this program "Advanced Power Manager", e.g. monday-friday at 1800 hours. Besides that, I have to change crontab and ensure that within an appropriate number of minutes from boot-up-time, run the download-program:
#minute hour mday month wday who command
........... (something) ............
07 18 * * 1-5 root cd /volume1/getData; python data_downloader.py
As you can see, I now have 7 minutes to boot the system (the startup-scripts take about 4 minutes, I think - I added some extra minutes, because maybe in the future with software updates, it'll take longer to boot up).
But this solution is stupid, because I have to change the boot-up time two places and ensure that the crontab-job starts 7 minutes after the power-on-utility wakes up the system...
Here's my idea - new crontab-file:
#minute hour mday month wday who command
........... (something) ............
* * * * 1-5 root cd /volume1/getData; python clever_job.py
This runs every minute. I still need to run "python data_downloader.py" from inside "clever_job.py", but ONLY if a certain condition is met...
Which condition? I found out that there's a file on my system with 2 lines:
-----------------
cat /volume1/@appstore/AdvancedPowerManager/config/default
exp_on=Mon-Fri at 18:00
mode=expert
-----------------
This tells when to wake up by hardware/BIOS clock or something (I guess there's a batteri or maybe it just uses a bit standby-power for this). I think that my "clever_job.py" should run every minute and check the current day and time of the week.
*IF* now/today mets the condition of the first line of the /volume1/@appstore/AdvancedPowerManager/config/default (which is: Mon-Fri at 18:00) and *IF* /proc/uptime indicates that the system has been turned on within maybe 5 minutes, *ONLY* in that case should the "python data_downloader.py" command be issued from cd /volume1/getData...
But the problem is: What if today is tuesday or wednesday? This is not so easy for me to solve, because I guess that first I should convert the string "Mon-Fri" to numbers, i.e. 1-5 and next I need to get todays weekday-number, i.e. Wed = 3:
Wed Apr 10 20:44:39 CEST 2013
After that I need to check if it's true that e.g. Mon < Wed < Fri or (1 < 3 < 5), yes this is true... But Saturday is not true: (1 < 6 < 5)...
Last problem is to add maybe 5 minutes to the string: "18:00" and if "now" is e.g. Wednesday and the time is e.g. "18:03", which is "18:00" < "18:03" < "18:05" AND if the system has just been turned on, then run "python data_downloader.py"...
With this solution, I only have to edit the power-on time from within "Advanced
Power Manager" - can somebody tell me what you think of this and/or maybe also help with code snippets?
I would be grateful for your help, thanks... I think this is the direction for me to go into now...