1.

Solve : How to make a simple Cron script for Linux??

Answer»

Can anybody here tell me how to WRITE a simple Cron script?
Basic job:
It will run daily.
It will copy a jpg IMAGE file

Now when I get that far, I will rotate the file naming from a list
The list is this:
sig1 sig2 sig3 sig4 sig5 sig6 sig7

It will start by making sig.jpg from the next item in the list.

So on Monday, visitors will see the image from the sig1 file.On Tuesday, the sig2 file. And so on.

I guess I could just do this with FrontPage extensions, but I don't think the server has that. I have not seen it for a long time. Maybe it has been forgotten.

It does not have to be Cron. Any suitable script will do.
Any suggestions?
i think this will work

Code: [Select]#!/bin/bash
SYMLINK="$HOME/work/temp/geek9pm-cron/sig.jpg"
prefix="sig"
ext="jpg"
num="$(date '+%u')"
filepath="$HOME/work/temp/geek9pm-cron/files"
filename="$prefix$num.$ext"
todaysimage="$filepath/$filename"
if [ -e "$todaysimage" ]
then
ECHO "Source: $todaysimage"
echo "Dest: $symlink"
if ln -sf "$todaysimage" "$symlink";
then
echo "Done"
exit 0
else
echo "Link FAILED"
exit 1
fi
else
echo "Image $todaysimage doesn't exist, exiting"
exit 1
fi

then

Code: [Select]crontab -e
add line

Code: [Select]1 0 * * * /path/to/yourscript
by default Monday is day 1, Sunday is day 7, so this would symlink files/sig1.jpg to sig.jpg at 12:01 Monday morning

if your web server serves symlinks this should work
otherwise just use cp instead of ln -sf Many thanks, I will give it a try.



Discussion

No Comment Found