LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Perl script not running via cron (https://www.linuxquestions.org/questions/linux-newbie-8/perl-script-not-running-via-cron-4175541378/)

tanveer 05-01-2015 09:16 PM

Perl script not running via cron
 
Hi All,

I have perl script which I am trying to run on 1st Monday via cron job.
So I scheduled it as follows:

0 0 1-7 * * root ["$(date '+%a')" = "Mon"] && /usr/bin/perl script.pl

But then it didn't run so checked cron log and it seemed like its missing the command. so added a \ in front of %a and then it picked up the whole command as per cron log.

But still it didnt ran the script. I then change the script to just && echo "test">/tmp/test

Still nothing. if I run it as /usr/bin/perl script.pl it runs though

Thanks in advance.

tanveer 05-01-2015 09:54 PM

my bad .. resolved ..
this worked..

* * * * * root [ "$(date '+\%a')" == "Fri" ] && echo "test">/tmp/test

unSpawn 05-02-2015 05:50 AM

Quote:

Originally Posted by tanveer (Post 5356452)
(..) run on 1st Monday

Note what you used is weekday name and what you need is more like '[ $(date '+%e') -le 7 -a "$(date '+%a')" == "Mon" ] &&;'.


Quote:

Originally Posted by tanveer (Post 5356452)
&& echo "test">/tmp/test

You realize that using predictable file names is a real bad way of testing things, especially if you're root, right?


All times are GMT -5. The time now is 07:17 AM.