[SCRIPT] create-autorun.sh
-
- New here
- Posts: 4
- Joined: Sat Jun 01, 2019 3:11 am
Re: [SCRIPT] create-autorun.sh
That looks just like what I need and much simpler than the other solutions I'd found - will give it a shot next week
Thanks again
Thanks again
-
- New here
- Posts: 6
- Joined: Mon Aug 12, 2019 4:55 pm
Re: [SCRIPT] create-autorun.sh
Awesome script! Thank you very much!
Works great on TS-451+ running QTS 4.4.1.1031
Works great on TS-451+ running QTS 4.4.1.1031
- OneCD
- Guru
- Posts: 12160
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
-
- Getting the hang of things
- Posts: 98
- Joined: Thu Mar 29, 2018 7:48 am
Re: [SCRIPT] create-autorun.sh
Hi
I have installed your script months ago; working great thus far.
Then lately, I wrote another script (auto_delete.sh) but could not get it to work.
Autorun log only gives this:
Sat Feb 8 05:17:07 HKT 2020 - /share/CACHEDEV1_DATA/.system/autorun/scripts/auto_delete.sh
When I run the sh file from terminal, I always get "command not found".
#!/usr/bin/env bash
MAXAGE=7776000
LOGFILE='/share/CACHEDEV1_DATA/.system/autorun/scripts/log.txt'
FOLDER="/share/Multimedia/VIDEO/Movies/TEMP"
FILE="${FOLDER}/DELETE.ME"
echo "==================================================" >> "$LOGFILE"
echo "== auto_delete.sh $(date) ==" >> "$LOGFILE"
echo "==================================================" >> "$LOGFILE"
echo "${FILE}" >> "$LOGFILE"
if test -e "${FILE}"
then
AGE=$(( $(date +%s) - $(date +%s -r "${FILE}") ))
if [ $AGE -gt $MAXAGE ]
then
echo "RESULT: $AGE seconds, OVERDUE" >> "$LOGFILE"
else
echo "RESULT: $AGE seconds, Not Overdue" >> "$LOGFILE"
fi
else
echo "RESULT: File not found. Creating file" >> "$LOGFILE"
touch "${FILE}"
fi
echo "" >> "$LOGFILE"
1. The file does have +x
2. Syntax wise, the script works if I manually copy-paste the script to terminal.
3. Internet suggests that I have to convert the file to UNIX format which I already did.
What is wrong? I run out of ideas.
thanks for helping.
I have installed your script months ago; working great thus far.
Then lately, I wrote another script (auto_delete.sh) but could not get it to work.
Autorun log only gives this:
Sat Feb 8 05:17:07 HKT 2020 - /share/CACHEDEV1_DATA/.system/autorun/scripts/auto_delete.sh
When I run the sh file from terminal, I always get "command not found".
#!/usr/bin/env bash
MAXAGE=7776000
LOGFILE='/share/CACHEDEV1_DATA/.system/autorun/scripts/log.txt'
FOLDER="/share/Multimedia/VIDEO/Movies/TEMP"
FILE="${FOLDER}/DELETE.ME"
echo "==================================================" >> "$LOGFILE"
echo "== auto_delete.sh $(date) ==" >> "$LOGFILE"
echo "==================================================" >> "$LOGFILE"
echo "${FILE}" >> "$LOGFILE"
if test -e "${FILE}"
then
AGE=$(( $(date +%s) - $(date +%s -r "${FILE}") ))
if [ $AGE -gt $MAXAGE ]
then
echo "RESULT: $AGE seconds, OVERDUE" >> "$LOGFILE"
else
echo "RESULT: $AGE seconds, Not Overdue" >> "$LOGFILE"
fi
else
echo "RESULT: File not found. Creating file" >> "$LOGFILE"
touch "${FILE}"
fi
echo "" >> "$LOGFILE"
1. The file does have +x
2. Syntax wise, the script works if I manually copy-paste the script to terminal.
3. Internet suggests that I have to convert the file to UNIX format which I already did.
What is wrong? I run out of ideas.
thanks for helping.
You do not have the required permissions to view the files attached to this post.
Last edited by jsteng on Sat Feb 08, 2020 7:58 am, edited 1 time in total.
- OneCD
- Guru
- Posts: 12160
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] create-autorun.sh
Can you please post a terminal transcript demonstrating this? Need to see the command prompt, your command and the response from the shell.
Copy-paste it if you can, but a screenshot is also acceptable.
-
- Getting the hang of things
- Posts: 98
- Joined: Thu Mar 29, 2018 7:48 am
Re: [SCRIPT] create-autorun.sh
Hi
please check previous post. I added a screen shot.
(I could not attach screen shot on new post?)
thanks
please check previous post. I added a screen shot.
(I could not attach screen shot on new post?)
thanks
- OneCD
- Guru
- Posts: 12160
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
-
- Getting the hang of things
- Posts: 98
- Joined: Thu Mar 29, 2018 7:48 am
Re: [SCRIPT] create-autorun.sh
running it via
/autodelete.sh gave me no such file or directory
ps. You might see discrepancy in autorun.log "auto_delete.sh" and the screenshot "autodelete.sh"
That is because, when it failed to run, after several attempts to resolve the problem, I run out of ideas, I renamed the file to "autodelete.sh"...
/autodelete.sh gave me no such file or directory
ps. You might see discrepancy in autorun.log "auto_delete.sh" and the screenshot "autodelete.sh"
That is because, when it failed to run, after several attempts to resolve the problem, I run out of ideas, I renamed the file to "autodelete.sh"...
You do not have the required permissions to view the files attached to this post.
- OneCD
- Guru
- Posts: 12160
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] create-autorun.sh
You’re getting closer. Please check the syntax again.
Whenever you wish to run a script located in the current directory, you need to explicitly specify the current directory [./] and script name.
Whenever you wish to run a script located in the current directory, you need to explicitly specify the current directory [./] and script name.
-
- Getting the hang of things
- Posts: 98
- Joined: Thu Mar 29, 2018 7:48 am
Re: [SCRIPT] create-autorun.sh
"./autodelete.sh" gives me
no such file or directory
no such file or directory
- OneCD
- Guru
- Posts: 12160
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
-
- Getting the hang of things
- Posts: 98
- Joined: Thu Mar 29, 2018 7:48 am
Re: [SCRIPT] create-autorun.sh
Ok...
Somehow, after opening the sh file with Ultraedit (text editor i am using) then saving it back, I forgot to use dos2unix... thus its not a valid unix file...
now it is ok running on shell.
rebooting QNAP and autorun.sh running it seems OK
BOTTOM LINE: dos2unix
I relied too much on ultraedit to do the auto conversion (from dos to unix file format)
thanks.
Somehow, after opening the sh file with Ultraedit (text editor i am using) then saving it back, I forgot to use dos2unix... thus its not a valid unix file...
now it is ok running on shell.
rebooting QNAP and autorun.sh running it seems OK
BOTTOM LINE: dos2unix
I relied too much on ultraedit to do the auto conversion (from dos to unix file format)
thanks.
-
- New here
- Posts: 3
- Joined: Sun Apr 16, 2017 1:41 am
Re: [SCRIPT] create-autorun.sh
Wow, this helped so much in getting my Windows samba shares to map correctly so that they are accessible to docker containers that need them. Thanks!
- OneCD
- Guru
- Posts: 12160
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
-
- Starting out
- Posts: 10
- Joined: Mon May 27, 2019 2:30 am
Re: [SCRIPT] create-autorun.sh
first of all thank you for writing this script, and helping out who's in need
running scripts on my Qnap at startup has been driving me crazy for sometime, I tried everything and failed, including your method, I have only two scripts which run certain applications in a screen session using '-dmS' flags to run the application with a named-deattached session, in my '/var/logs/autorun.log' I can see that both of my scripts got executed after booting, but checking with 'screen -ls' I can see that nothing is actually running, keep in mind that both of my scripts are executable, and when the boot is completed, if I go to the scripts directory and execute them via './thescript.sh' they'll run just fine, Also if I run the 'autorun.sh' file located in '.../.system/autorun/autorun.sh' it will run my scripts just fine, Maybe at the boot time the scripts are executed using a different user than admin ? even if that's the case, I'm sure that my applications aren't running by checking with 'pidof' or 'ps -a', any ideas ?
running scripts on my Qnap at startup has been driving me crazy for sometime, I tried everything and failed, including your method, I have only two scripts which run certain applications in a screen session using '-dmS' flags to run the application with a named-deattached session, in my '/var/logs/autorun.log' I can see that both of my scripts got executed after booting, but checking with 'screen -ls' I can see that nothing is actually running, keep in mind that both of my scripts are executable, and when the boot is completed, if I go to the scripts directory and execute them via './thescript.sh' they'll run just fine, Also if I run the 'autorun.sh' file located in '.../.system/autorun/autorun.sh' it will run my scripts just fine, Maybe at the boot time the scripts are executed using a different user than admin ? even if that's the case, I'm sure that my applications aren't running by checking with 'pidof' or 'ps -a', any ideas ?