Assuming it ran in the directory where your *jpg files existed (root you say) the script would work. The reason it doesn't work is likely because of assumptions like that and that it knows where to get the commands (mv, mkdir, date).
When you are logged in you have an "environment" that includes things such as CWD, PATH, TERM and various other things. It is PATH that lets you know where to find commands. CWD is current working directory. Typically on login your CWD is your HOME directory. This environment is created by your /etc/bashrc, /etc/profile, $HOME/.profile, $HOME/.bash_profile, $HOME/.bashrc and/or other files.
However when you run a script in cron it does not get that "environment" but rather a much more rudimentary environment because it isn't "logging in" so doesn't execute all the above files.
Accordingly your script should contain most of that information:
e.g.
Code:
/bin/mkdir /temp_date
/bin/mv /*jpg /temp_date
/bin/mv /temp_date /`/bin/date +%Y%m%d`
So you see it is told exactly where to find the 3 commands it is using (/bin - not all commands are there just happens all 3 of these are). It is also told to use "/" (root) directory as part of path for the directories you're creating.
Another assumption to address is that it is using the shell you are. In fact it uses a basic shell so when writing scripts it is a good idea to include an intepreter line to tell it what shell or interpreter you want it to run as. So to run it as bash:
Code:
#!/bin/bash
/bin/mkdir /temp_date
/bin/mv /*jpg /temp_date
/bin/mv /temp_date /`/bin/date +%Y%m%d`
Note that the "#!" is a special syntax - normally "#" means comment (lines that don't get executed) but "#!" at beginning of first line means to use what follows on the line to execute the remainder of the script.
You don't need to do the two moves however. Your script could have one less step:
Code:
#!/bin/bash
/bin/mkdir /temp_date
/bin/mv /*jpg /`/bin/date +%Y%m%d`
You might also not want to use / as your directory for storing pictures. This is the root directory and cluttering it up with other files can make diagnosing system issues later a little difficult.
e.g. mkdir /jpegs then use that for your daily captures then change the script to:
Code:
#!/bin/bash
/bin/mkdir /jpegs/temp_date
/bin/mv /jpegs/*jpg /jpegs/`/bin/date +%Y%m%d`