The first step would be to add the strict and warnings pragmas and fix the problems they point out. Those 2 pragmas should be in every Perl script you write.
Code:
#!/usr/bin/perl
use strict;
use warnings;
Next, you need to add some debugging statements and send the output to a file. Make sure you open the file in a world writable directory. The debug statements should test that the script can both read and execute each of the system commands.
As written, I would not expect the "service named restart" command to work for the following 2 reasons. 1) It lacks the path to the command. 2) The
service command is a privileged command, i.e., requires root privileges which the user account that cron runs under (which I think is "nobody") most likely doesn't have.