0

I have a very simple bash script

#!/bin/bash
count=`ls | wc -l`
mkdir Folder$count

This script works when I execute it manually but fails to execute in the crontab. All the permissions on the file for execution are okay.

I have tried the following, put the output of the PATH variable in the crontab entry. Below is my my config in the crontab.

PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/workspace
* * * * * /opt/workspace/makedir

In /var/log/syslog, I could see that the cron executes the script every minute. So what am I missing?

1
  • How do you mean "fails to execute in the crontab"? What are the errors? What are the symptoms? Commented May 8, 2014 at 1:42

1 Answer 1

1

I guess the working directory of cron is /. add a cd /path/to/your/working/directory to your script and it'll probably work.

The default cron executing environment is very limited, but I think ls, wc and mkdir will be found

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.