Need help w/ first cron job

software development

#1

hello, i’m reading the other php cron job topic but it’s too advanced for me.

I’m taking a unix course this term, but we’ve just started.

Anyhow, I want to make a job that shuffles my playlist.xspf files every 12am. ie all it does is :

mv pl1 pl-1; mv pl2 pl1; mv pl pl2; mv pl-1 pl;

Will someone show me how to do this in php? I know php syntax, and can (hopefully) figure the crontab file settings and execution for myself. Thanks so much!

http://listenlight.net


#2

Why not just do it with a shell script?

#!/bin/bash
mv pl1 pl-1
mv pl2 pl1
mv pl pl2
mv pl-1 pl

Then have the cronjob run that script. It cuts out any problems that might arise from using PHP and keeps things simple.

If you don’t know, a shell script is similar to a batch file on a windows box. Just copy all of that portion above into playlistShuffle.sh (or whatever you want to call it) and run it with “bash playlistShuffle.sh” (it’s a good idea to use absolute paths very everything when using cron though, but that gives you the idea).

Check out Gordaen’s Knowledge, the blog, and the MR2 page.


#3

do I need semicolons at the end of the lines?

so the crontab file would look like

  • 0 * * * /bin/bash /home/username/domain/scripts/shuffle.sh

for instance?

what about the file permissions? what should they be? thanks :slight_smile:

http://listenlight.net