Dartagnan324
asked on
Perl cron jobs
Hi
Everyday, I run ./apple which outputs some data on the screen.
I need to create a cron job to run this command on weekends and print the data into a file I can get later on monday.
From what I gathered so far, you just do:
20 9 * * 6 /usr/local/program.pl
will run program.pl at 9:20 on Saturday. However, what do I do if apple requires "./apple" to run and what is some sample code to output the data to a file?
Dartagnan
Everyday, I run ./apple which outputs some data on the screen.
I need to create a cron job to run this command on weekends and print the data into a file I can get later on monday.
From what I gathered so far, you just do:
20 9 * * 6 /usr/local/program.pl
will run program.pl at 9:20 on Saturday. However, what do I do if apple requires "./apple" to run and what is some sample code to output the data to a file?
Dartagnan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So 20 9 * * 6 /usr/local/apple >> myfile will create a new file named "myfile" containing the data that ./apple usually outputs?
Do I need to worry about permissions?
Thx!
Do I need to worry about permissions?
Thx!
>> myfile will create myfile if it doesnt exist and write the data that ./apple normally does. If the file already exists, ./apples data will be apended to it. If you want to overwrite the file every time just use 1 > instead of 2. Your permissions should be ok as long as the user who owns the crontab entry has write access to the directory myfile will be created in.
ASKER
hmm.....I just tested 55 10 * * 4 /usr/local/apple >> myfile and it gives Usage: /usr/local/apple [logfile] rather than the output i usually get. How do you fix this?
Thx!
Thx!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot!
20 9 * * 6 /home/dartagnan/apple
-- or--
20 9 * * 6 /home/dartagnan/apple >/home/dartagnan/apple.res
-- or --
20 9 * * 6 /home/dartagnan/apple >/home/dartagnan/apple.res
Since cron will mail to the user owning the crontab any output generated from a cron job the first example will send the output from running apple to what ever user set up the crontab. The second example will write everything that apple prints to STDOUT to apple.results and the last example will write erverything printed to STDERR & STDOUT to that file.