3

I made a short script on one server to backup a folder and send it via FTP to another server. I'm trying to set it to run every minute using crontab. It works perfectly when I run it manually, but when cron runs it, nothing appears to happen (i.e. no file received on the other end). As I said in the title, the task shows up in syslog as if everything is A-OK.

Here's the script:

#! /bin/sh

cd /root

FILENAME="backup-$(date +%b_%d_%Y_%H:%M).zip"

zip -r $FILENAME folder

ftp -in 74.131.78.127 24721 << EOF > ~/log.txt 2>&1

user myusername 
binary
cd Desktop/backups
mput $FILENAME

EOF

rm $FILENAME

Crontab entry:

* * * * * /root/backup.sh

I entered this using crontab -e.

Parker Kemp
  • 181
  • 1
  • 1
  • 12

2 Answers2

1

I figured out my problem. The actual root did not have permissions to my ineptly named /root folder. A simple chmod -R 707 /root solved it.

Parker Kemp
  • 181
  • 1
  • 1
  • 12
  • You can also add the script to root's crontab sudo crontab -eand the job will run as root. This might be another way to get around your permissions problem. – Dan Aug 23 '13 at 15:17
-1

It is helpful to set up to create a separate cron.log, which is more useful.

This Q&A describes the process:

16.04: How do I make cron create cron.log and monitor it in real time?

Also in this answer is the instructions to create a wcron command that displays it is near-real-time.

Plus, it links to another answer,

How to change cron log level?

that shows how to change the log level to include more than just the start of jobs - level 15 will show errors and end time, also.

Perhaps your answer is in the log output.

SDsolar
  • 3,169