linux - Script does not run under cron but runs manually again -
i sorry asking again, i've tried advices. have 2 scripts in /var/tpbackup_script/
. first one:
mysqldump -u root -ppassword teampass > /var/tpbackups/tpbackup_$(date +"%y-%m-%d").sql
corresponding cronjob in /etc/crontab
20 9 * * * root sudo sh /var/tpbackup_script/tpbackup_script
this script works in crontab. good. second script not run:
s3cmd sync /var/tpbackups s3://pwdmgmt
corresponding cronjob in /etc/crontab
:
25 9 * * * root sudo sh /var/tpbackup_script/tpsyncs3_script
this 1 fails. if run manually in terminal:
sudo sh /var/tpbackup_script/tpsyncs3_script
then works perfectly. tried:
1) trying add shebang #!/bin/sh beginning of script
2) renaming script tpsyncs3_script.sh
3) have added script cron.daily , in list of daily cron tasks (i see command run-parts --test /etc/cron.daily
)
no success.
here /etc/crontab file:
# /etc/crontab: system-wide crontab # unlike other crontab don't have run `crontab' # command install new version when edit file # , files in /etc/cron.d. these files have username fields, # none of other crontabs do. shell=/bin/sh path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 16 9 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) 20 9 * * * root sudo sh /var/tpbackup_script/tpbackup_script 25 9 * * * root sudo sh /var/tpbackup_script/tpsyncs3_script.sh > /var/tpbackup_script/sync_log.txt #
all permissions on scripts set sudo chmod 777
.
, way. sync_log.txt created after cronjob, it's empty.
appreciated
had same problem. solved adding option specify location of s3cfg:
--config /root/.s3cfg
e.g:
s3cmd sync --config /root/.s3cfg /var/tpbackups s3://pwdmgmt
Comments
Post a Comment