Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

My cron and scripting skills are very poor, but I need to run a job every 5 minutes by user 'cpc'. So I created a script and left it at /root.

My crontab -e entry about it is:

0-59/5 * * * * /root/

And this script ( is:

su cpc
cd /home/cpc/data-integration 
/bin/bash -rep="01" -job="MainLoad" -user="admin" -pass="admin" -level="Basic"`

But it is not called or run at any moment. What am I missing here?

Thanks in advance!

share|improve this question
You definitely want to check a question I asked about an hour ago. It has an answer by Stephane Chazelas that explains how you can create an interactive shell that is identical to the environment your cron job will see. If you walk through his little procedure, you get a prompt and you can test your script step by step and see where it fails. The only gotcha is that the first command after the procedure has to be /bin/bash, without the she-bang #!. – jippie Nov 23 '12 at 21:50

2 Answers 2

up vote 3 down vote accepted

That su is why it fails, that launches an interactive shell. Why not add it to the crontab of the cpc user instead? crontab -e -u cpc

share|improve this answer
and put the script under /home/cpc? – gtludwig Nov 23 '12 at 20:06
I would not even use but make this the crontab line: */5 * * * * cd /home/cpc/data-integration && /bin/bash -rep="01" -job="MainLoad" -user="admin" -pass="admin" -level="Basic"` – Dennis Kaarsemaker Nov 23 '12 at 20:08
following your suggestion, I left the cpc user's crontab like this: */5 * * * * cd /home/cpc/data-integration && /bin/bash -rep="01" -job="MainLoad" -user="admin" -pass="admin" -level="Basic" > /dev/null 2>&1 – gtludwig Nov 23 '12 at 20:15
no luck still... now trying without > /dev/null 2>&1 – gtludwig Nov 23 '12 at 20:25
try >> /tmp/my_cronjob.log 2>&1 – Dennis Kaarsemaker Nov 23 '12 at 20:30

This really should be a comment rather than an answer, but I don't yet have enough reputation...

What do the permissions on the script look like? ie, if you run ls -l /root/, is the script set to be executable by root? If not, your fix may be as simple as chmod +x /root/

share|improve this answer
yes, its permissions are 755. AFAIK it should be enough. – gtludwig Nov 23 '12 at 19:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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