Your output is written to a file called dumpfile_[timestamp].txt
. But where is that file?
Your command contains no directory path for that file. So it will be written to the current directory. The current directory for a cronjob is the home directory for the user that owns the cronjob. Have you tried looking there?
It's always better to be more specific about which directory you want the files written to. Two ways to do that are:
- Change to the directory before running your command
*/2 * * * * cd /some_directory_path && /usr/bin/perl /tmp/test.pl
- Include the full path in your Perl program
-o /some_directory_path/dumpfile_" . $timenow . ".txt
Update: Ok, take two.
Who owns this cronjob? Any output from the cronjob will be emailed to the owner. And there's definitely output as you have a print()
statement. Any errors will be included in the same email. Do you get that email? What's in it?
If you don't get the email, you can change the address that the email is sent to by adding a MAILTO
parameter to the crontab. It will look like this:
MAILTO=someone@example.com
*/2 * * * * /usr/bin/perl /tmp/test.pl
Bear in mind that the server might not be set up to send external email, so you might need to use the local mail
program on the server.
If you can't get the email to work out, you could look for cron errors in /var/log/syslog
(or, on a systemd
system, try journalctl _COMM=cron
).
The print()
output is going somewhere. You need to track it down.