The first thing I would suggest is to see if your Perl script is running fine. Normally what cron does is to email the output of the script or the errors if any exists to the email address provided.
As I wanted to run my script daily and already had an email function inside my script I did not use it although for simpler scripts you can use it. You just need to write a line at the top of crontab i.e.
Now the main part i.e. running a Perl Script. Normally they require an environment variable to be set as cron does not execute in the same environment as your script does when you do it manually. There are many things you can do but the best thing that I found out was to add four lines at the top of your script
This is basically telling where your Modules are situated and as cron does not know. You can just copy paste this as most of the time it is the same else just write the path of the folder where your Perl Modules are stored.
Now one thing you should check is try going out of all the folder and run your script giving the whole path and see if it is running or not i.e. ‘$ perl /home/admin/Desktop/1.pl’.
If it runs then you are ready to set up your cron Job else edit the paths that I have given with the ones that are shown in the error message and try again.
Now open a terminal and type ‘crontab –e’. This enables you to edit the crontab file.
Now if you are using UBUNTU you are given an option of using the NANO editor select it its easy and if you are using Fedora then you have to use ‘vi’. Don’t know learn it.
Now start typing the command
‘00 4 * * * perl /home/admin/Desktop/2.pl’
This command will run your perl Script every day at 4 in the morning. The * * * are different combinations of time day week month and year. You can easily lookup that on the internet.
TADA!!!!! Your cron job is ready to run.