Jump to content

UNIX shell and MySQL scripts


diode

Recommended Posts

Hello,

 

I'm trying to make a script in which I want to use variables to store the output of: date +%m as well as date +%d and date +%Y.

 

Basically what the goal is, is I want/need to learn how to store the output of commands in variables in shell scripts. Nothing I try works.

 

I am going to have a cron job execute at 12:00 am every day. The cron job will execute a batch file which in turn executes a mysql script. I have a message board, and I want everyone's board points to increase by 1 if they have posted during the day that just ended. I'm going to have a special table that contains their userid and 3 integer fields for month, day, and year for the date they posted. I need mysql to query this table every day at 12:00 am. I need mysql to query this table and return every record for the previous day, such as current date minus one.

 

The reason I want it to do arithmetic to find if they posted during the previous day is because if I merely add a record to this table when they post for the first time during a day, and automatically update a user's points total if a record containing their userid was found, somebody could possibly post a message like at 12:01 am or something BEFORE the query is done running, and either update this person who posted during the day AFTER the one I am checking for, or actually delete this entry if the person posted after the update query, and before the query that will delete all the users' records for the previous day, thereby treating it as if they had posted during the previous day. Then their record would be gone in the table, and if they don't post again for that day, their points wouldn't get updated during the next cron job.

 

It's difficult to explain, but the explanation is more difficult than the concept actually is. If anyone could provide help, or simple scripts to show me how this is done, I'd greatly appreciate it. I know it can't be that difficult really, but sometimes little things are more annoying and elusive than bigger things.

 

Thanks again in advance,

diode :D

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.