get cron jobworking

Status
Not open for further replies.

onthax

Explorer
Joined
Jan 31, 2012
Messages
81
I've made a shell script to rsync to a remote server, the script is

Code:
!/bin/sh

task=backup
target=daedalus

tmux list-sessions | grep "$task$target" > .$task$target.pid

if [ -s .$task$target.pid ] ; then
echo "$task$target is Running "
else
tmux new-session -s $task$target -d ./$target/$task$target.sh
fi


which runs fine when I try it from the shell

i've added it as a cron job in the freenas gui

User: Onthax
every 5 minutes, every 1 day, every 1 month, every month, every day of the week

however it doesnt make the tmux session or start an rsync, any ideas?
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
It could be the folder where the script is executed by cron and where you want to create the .pid file doesn't have write permission. Maybe you could have it echo `pwd` to verify where it's being executed or specify a full path such as /tmp/$task$target.pid or something also. You could also add some echos to see which branch of your IF is being executed. It looks like $target = daedalus, but maybe you need /mnt before it?
 

onthax

Explorer
Joined
Jan 31, 2012
Messages
81
It could be the folder where the script is executed by cron and where you want to create the .pid file doesn't have write permission. Maybe you could have it echo `pwd` to verify where it's being executed or specify a full path such as /tmp/$task$target.pid or something also. You could also add some echos to see which branch of your IF is being executed. It looks like $target = daedalus, but maybe you need /mnt before it?

Cheers, that fixed it, didnt think about where cron was running from, added a $HOME to the front, now it's all working grand
 
Status
Not open for further replies.
Top