• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Problem with cronjob  (Read 1701 times)
ebp
Newbie
*

Karma: 1
Posts: 24


View Profile
« on: August 20, 2009, 02:29:20 AM »

Hi

I'm running some cronjob on my sheevaplug but one of them doesn't work. My crontab is:

Code:

# m h  dom mon dow   command

@hourly /flexget/flexget.py -q

*/10 * * * * /flexget/watchdog.sh

@hourly gpodder -r


The script i have problems with is watchdog, when i run it from the commandline it works fine, but as a cronjob it doesn't work. The content of the script is: 

Code:
#!/bin/bash

# Watch dir, may contain spaces:
watchdir="/mnt/mybook/Torrent/torrentfiler/showrss/"

# move file to a subdirectory? if Commented out, it'll removed remove
# the torrent file.
# Note: Don't put a '/' before the path!
movesubdir="added/"


# Authentication "username:password":
tr_auth="brugernavn:kodeord"

# Transmission host "ip:port":
tr_host="127.0.0.1:9091"

# Verbose?
verbose=1

#############################################
time=$(date "+%Y-%m-%d (%H:%M:%S)")
if [ -n "$tr_auth" ]; then
    tr_auth="--auth=$tr_auth"
fi

for file in "$watchdir"*.torrent
do
    if [ -f "$file" ]; then
        if [ -n "$verbose" ]; then echo "$time: $file added to queue."; fi

        /usr/bin/transmission-remote "$tr_host" "$tr_auth" -a "$file" > /dev/null
        # give the remote some time to process
        sleep 5

        if [ $movesubdir ]; then
            if [ -d "$watchdir$movesubdir" ]; then
                mv "$file" "$watchdir$movesubdir"
            else
                mkdir "$watchdir$movesubdir"
                mv "$file" "$watchdir$movesubdir"
            fi
        else
            rm "$file"
        fi
    else
        if [ -n "$verbose" ]; then echo "$time: No torrent in $watchdir."; fi
    fi
done

exit 0



Hope you can help Smiley
« Last Edit: August 21, 2009, 01:46:24 AM by ebp » Logged

birdman
Sr. Member
****

Karma: 4
Posts: 443


View Profile WWW
« Reply #1 on: August 20, 2009, 04:42:11 PM »

Not a good idea to post username/pwd to a forum.

If that's all of the script then how do you know it isn't working?  It doesn't do anything apart from set some variables!

If the posting was incomplete then the problem *may* be that you set a specific PATH in your interactive account, which won't be set for cron.

Getting the script to write all of its output to a log when run non-interactively would help you:

Code:
[ -t 0 ] || exec > /mnt/mybook/Torrent/cron.log 2>&1
Logged

ebp
Newbie
*

Karma: 1
Posts: 24


View Profile
« Reply #2 on: August 21, 2009, 01:42:57 AM »

I didn't post my password, brugernavn and kodeord is the danish words for username and password, i replaced them on purpose.


If i run [ -t 0 ] || exec > /mnt/mybook/Torrent/cron.log 2>&1 there is no output.

I run cronjobs as root, don't know if that helps. 
Logged

ebp
Newbie
*

Karma: 1
Posts: 24


View Profile
« Reply #3 on: August 21, 2009, 01:47:36 AM »

This is embarrassing, i just realized that i didn't post the complete script. I have edited the original post so it's correct.   
Logged

ebp
Newbie
*

Karma: 1
Posts: 24


View Profile
« Reply #4 on: August 21, 2009, 07:10:26 AM »

I have fixed it, but i'm sorry i have wasted your time. The problem was my own fault, since i'm not terribly good at english i by mistake called the scrip whatchdog and it should have been watchdog as in the crontab. 
Logged

Pages: [1]
Print
Jump to: