Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Operating system Linux 2.6.18-028stab089.1
Parallels Plesk Panel version 9.5.4

Set up a test cron job in Settings>Scheduled Tasks>user "root">
* * * * * /var/www/cron/webcrontest.sh >/dev/null 2>&1
The script contains this:

#!/bin/sh
echo "test" >>/var/www/cron/webcrontest.log

However, nothing gets output in that file.
How could I find out what's the problem? I have no access to the e-mail that the cron jobs could be sent to (not my host, trying to set up a cron job for a client because he doesn't listen when I say it's the sysadmins job).

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You are discarding any diagnostic information you might have by sending stdout & stderr to /dev/null (>/dev/null 2>&1).

Try redirecting the output to a file and seeing what it contains

* * * * * /var/www/cron/webcrontest.sh &>/tmp/webcrontest.out

Which will write stdout and stderr to /tmp/webcrontest.out.

Edit: From the comments, you have DOS line endings, use dos2unix to remove the ^M line endings

dos2unix /var/www/cron/webcrontest.sh 
share|improve this answer
    
Ok, I got this: /bin/sh: /var/www/cron/webcrontest.sh: /bin/sh^M: bad interpreter: No such file or directory What can I do about it? Edit: changed to /bin/bash, will see if it helps any. Edit2: /bin/bash - same thing. –  jurchiks Aug 11 '11 at 14:04
    
Use a linux editor to edit the file. You'll probably see ^M at the end of each line, remove them. Is this a file that you edited on windows and uploaded ? –  Iain Aug 11 '11 at 14:07
    
Just edited it with Notepad++, changed EOL and it works now. I'll test it with some more stuff. –  jurchiks Aug 11 '11 at 14:11
    
Yeah, that works too. lots of solutions when you know what the problem is ;) –  Iain Aug 11 '11 at 14:16
    
Well, everything works now, thanks for help :) –  jurchiks Aug 11 '11 at 14:25
add comment
dos2unix /var/www/cron/webcrontest.sh
share|improve this answer
    
EOL>Unix format, UTF-8 without BOM... what do I need to convert there? –  jurchiks Aug 11 '11 at 14:09
add comment

Your Answer

 
discard

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.