Cron VPN Client start/scp/stop

Hi,

Anyone can help me on how my script will run on crontab, When I manually run my script, it work. But when I put in cron didn't work.

#crontab schedule
00 16 * * * /home/scriptdir/myscript.sh
# myscript.sh
#!/bin/bash
echo "mypassword"| sudo -S /etc/init.d/vpnclient_init start
cd /home/vpnclient
vpnclient connect "myprofile" user myusername pwd mypassword
scp myusername@192.168.2.8:/destination/filename.txt target/filename.txt
echo "mypassword"| sudo -S /etc/init.d/vpnclient_init stop
exit 0

Thanks in Advance,
FSP

Add PATH=path

  1. in crontab
    first line if supported else add PATH in script

  2. In Script
    export PATH=/bin:/whatever/bin:/where_my_bin:
    ... I guess you got the point ... Crontab does not know PATH from where it can pick binaries...

  3. Add actual location of each command you run
    vpnclient, scp, echo etc are unknown

hi chakrapani,

excellent, it works well. thanks for the help.

regards,
fsp