1

I'm trying to run an sh file to move files around with scheduled tasks. See GUI pic. The result from "run Selected Task" is:

/tmp/tmp8yj5zs: line 1: /home/dan/Foscam/move-video.sh: Permission denied
Press ENTER to continue and close this window.

If I add sudo to the front I get:

 sudo: /home/dan/Foscam/move-video.sh: command not found
Press ENTER to continue and close this window.

The Sh file is

#!/bin/bash
/usr/bin/find /home/foscam/FI9803P_C4D655404959/record/ -type f -mtime +3 -exec mv '{}' /home/dan/Foscam/Week_2/ \;
/usr/bin/find /home/dan/Foscam/Week_2/ -type f -mtime +3 -exec mv '{}' /home/dan/Foscam/Week_3/ \;
/usr/bin/find /home/dan/Foscam/Week_3/ -type f -mtime +3 -exec mv '{}' /home/dan/Foscam/Week_4/ \;
/usr/bin/find /home/dan/Foscam/Week_4/ -type f -mtime +3 -exec rm -f {} \;

Can anyone suggest what I'm doing wrong?

enter image description here

It does not seem like images is working for me so the command is home/dan/Foscam/move-video.shrun as Xapplication

#!/bin/sh at the top of the file seems to do the same.

closed as off-topic by pa4080, Zanna, David Foerster, Elder Geek, George Udosen Feb 25 '18 at 17:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This describes a problem that can't be reproduced, that seemingly went away on its own or was only relevant to a very specific period of time. It's off-topic as it's unlikely to help future readers." – pa4080, Zanna, David Foerster, Elder Geek, George Udosen
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    running your script directly /home/dan/Foscam/move-video.sh is working? did you try adding bash to bash /home/dan/Foscam/move-video.sh in TASK command section? does the script is executable? – αғsнιη Jul 28 '17 at 5:08
  • It was executable but when I checked it was not so must have gotten changed during an edit. It now runs. It is nto doing what I wnat but at least now I can try and debug. – Dan Jul 28 '17 at 19:22
  • 1
    Yes, also note that with your script you are just deleting everything in this path /home/foscam/FI9803P_C4D655404959/record/ in result!! be aware of this – αғsнιη Jul 28 '17 at 19:35
  • Probably you want it the other way round, first delete week4 dir, then move 3 to 4, move 2 to 3, move current to 2. Looks like a job for logrotate :) – user unknown Feb 23 '18 at 5:35
0

It has been a while but I did get it to work. At this point I don't quite remember how. I think I had issues with the file changing to a non executable. See below

#!/bin/sh
/usr/bin/find /home/foscam/FI9803P_C4D655404959/record/ -type f -mtime +3 -exec mv '{}' /home/dan/Foscam/Week_2/ \;
/usr/bin/find /home/dan/Foscam/Week_2/ -type f -mtime +6 -exec mv '{}' /home/dan/Foscam/Week_3/ \;
/usr/bin/find /home/dan/Foscam/Week_3/ -type f -mtime +9 -exec mv '{}' /home/dan/Foscam/Week_4/ \;
/usr/bin/find /home/dan/Foscam/Week_4/ -type f -mtime +13 -exec rm -f {} \;

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.