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 24721 << EOF > ~/log.txt 2>&1

user myusername 
cd Desktop/backups



Crontab entry:

* * * * * /root/backup.sh

I entered this using crontab -e.

  • Are you prompted for a password when its run manually? – Dan Aug 23 '13 at 15:08
  • No, but it turned out to just be a permissions issue. See my answer below. – Parker Kemp Aug 23 '13 at 15:13

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.

| improve this answer | |
  • 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

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.