Computer Locking GDB When Running Scheduled Task Planned maintenance scheduled April 23, 2019...
What makes a man succeed?
Is there any word for a place full of confusion?
Do I really need to have a message in a novel to appeal to readers?
Why are my pictures showing a dark band on one edge?
Can a Beast Master ranger change beast companions?
How were pictures turned from film to a big picture in a picture frame before digital scanning?
Draw 4 of the same figure in the same tikzpicture
Co-worker has annoying ringtone
Misunderstanding of Sylow theory
preposition before coffee
How do I tell what width chain my used chainring needs?
What are the discoveries that have been possible with the rejection of positivism?
Would it be easier to apply for a UK visa if there is a host family to sponsor for you in going there?
Why do early math courses focus on the cross sections of a cone and not on other 3D objects?
What does Turing mean by this statement?
Electrolysis of water: Which equations to use? (IB Chem)
Is it possible to force a specific program to remain in memory after closing it?
Sum letters are not two different
How to run automated tests after each commit?
A letter with no particular backstory
Trademark violation for app?
The Nth Gryphon Number
Strange behavior of Object.defineProperty() in JavaScript
Antipodal Land Area Calculation
Computer Locking GDB When Running Scheduled Task
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Invalid topology error when running script?Alternatives to Windows Explorer and ArcCatalog when copying a file gdbExplicitly locking a file geodatabaseScheduled Task - calling python through BATRunning Python script in Task Scheduler— Script will not runArcCatalog and python crash when running ConvertTimeField_managementPreparing geometry for psycopg2 using ArcPy without SHAPE@WKT?Error when saving into .gdb fileLayers left off when running python via Windows Task SchedulerArcPy script runs longer processing time in scheduled task than in ModelBuilder?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am currently downloading and unzipping a GDB every night through the use of Task Scheduler. Then I update a related GDB with the changed features in all of the feature classes.
My issue is, the scheduled task script to download and unzip the GDB is creating a lock on the nightly downloaded GDB. This isn't an issue until I run the script on the next night.
My "try and except" statement to delete the previous GDB allows for the script to run but obviously doesn't delete the script do to my computer lock still being on the GDB.
I tried to delete the lock manually through windows explorer but it doesn't work. It seems that the schedule task manager just holds on to the lock.
This is my first experience with running a script through task scheduler where I actually need to delete an object created by the task scheduler. the only way I've found to unlock the GDB is by restarting my computer.
Code:
import arcpy, os, re, zipfile, shutil
import datetime as dt
from arcpy import *
#Relevant Dates
today = dt.date.today()
yesterday = today - dt.timedelta(days = 1)
#Create Target GDB
print "Creating GDB {0}".format(today)
env.overwriteOutput = True
outLocation = r'C:XXXYYYYYZZZZZ GDB'####Update Location with Shared Drive
GDBName = "Pathfinder {0}.gdb".format(today)
GDB = os.path.join (outLocation, GDBName)
arcpy.CreateFileGDB_management (outLocation, GDBName)
#Copied File Location and Unzip
print "Finding Zipped Folder"
sourceFolder = r'C:XXXYYYYYZZZZZExtracts'####Update Location with Pathfinder Data Dump folder
for (dirname, dirs, files) in os.walk(sourceFolder):
for filename in files:
if filename.startswith ("Location"):####Update Location with Pathfinder extract
zipFl = os.path.join(dirname, filename)
print "Copying Zipped File: {0}".format(zipFl)
copyLoc = r'C:XXXYYYYYZZZZZ Export'#####Update Location with shared drive copied folder
shutil.copyfile(zipFl, os.path.join(copyLoc, os.path.basename(zipFl)))
print "Unzipping File: {0}".format(zipFl)
zipFl = os.path.join(copyLoc, os.path.basename(zipFl))
zipOb = zipfile.ZipFile (zipFl, "r")
zipOb.extractall(GDB)
zipOb.close()
#Clean Up Folders
print "Deleting File: {0}".format(zipFl)
os.remove(zipFl)
yesterName = "Pathfinder {0}".format(yesterday)
yesterdayGDB = os.path.join(outLocation, yesterName)
try:
arcpy.Delete_management(yesterdayGDB)
print "Deleted {0}".format(yesterdayGDB)
except: print "Pathfinder {0}.gdb does not exist".format(yesterdayGDB)
print "Finished"
ArcGIS 10.1
Intel(R) Xeon(R) CPU E5-1607 0 @ 3.00 GHz
RAM: 16 GB
64 bit OS
arcpy arcgis-10.1 file-geodatabase windows arccatalog
add a comment |
I am currently downloading and unzipping a GDB every night through the use of Task Scheduler. Then I update a related GDB with the changed features in all of the feature classes.
My issue is, the scheduled task script to download and unzip the GDB is creating a lock on the nightly downloaded GDB. This isn't an issue until I run the script on the next night.
My "try and except" statement to delete the previous GDB allows for the script to run but obviously doesn't delete the script do to my computer lock still being on the GDB.
I tried to delete the lock manually through windows explorer but it doesn't work. It seems that the schedule task manager just holds on to the lock.
This is my first experience with running a script through task scheduler where I actually need to delete an object created by the task scheduler. the only way I've found to unlock the GDB is by restarting my computer.
Code:
import arcpy, os, re, zipfile, shutil
import datetime as dt
from arcpy import *
#Relevant Dates
today = dt.date.today()
yesterday = today - dt.timedelta(days = 1)
#Create Target GDB
print "Creating GDB {0}".format(today)
env.overwriteOutput = True
outLocation = r'C:XXXYYYYYZZZZZ GDB'####Update Location with Shared Drive
GDBName = "Pathfinder {0}.gdb".format(today)
GDB = os.path.join (outLocation, GDBName)
arcpy.CreateFileGDB_management (outLocation, GDBName)
#Copied File Location and Unzip
print "Finding Zipped Folder"
sourceFolder = r'C:XXXYYYYYZZZZZExtracts'####Update Location with Pathfinder Data Dump folder
for (dirname, dirs, files) in os.walk(sourceFolder):
for filename in files:
if filename.startswith ("Location"):####Update Location with Pathfinder extract
zipFl = os.path.join(dirname, filename)
print "Copying Zipped File: {0}".format(zipFl)
copyLoc = r'C:XXXYYYYYZZZZZ Export'#####Update Location with shared drive copied folder
shutil.copyfile(zipFl, os.path.join(copyLoc, os.path.basename(zipFl)))
print "Unzipping File: {0}".format(zipFl)
zipFl = os.path.join(copyLoc, os.path.basename(zipFl))
zipOb = zipfile.ZipFile (zipFl, "r")
zipOb.extractall(GDB)
zipOb.close()
#Clean Up Folders
print "Deleting File: {0}".format(zipFl)
os.remove(zipFl)
yesterName = "Pathfinder {0}".format(yesterday)
yesterdayGDB = os.path.join(outLocation, yesterName)
try:
arcpy.Delete_management(yesterdayGDB)
print "Deleted {0}".format(yesterdayGDB)
except: print "Pathfinder {0}.gdb does not exist".format(yesterdayGDB)
print "Finished"
ArcGIS 10.1
Intel(R) Xeon(R) CPU E5-1607 0 @ 3.00 GHz
RAM: 16 GB
64 bit OS
arcpy arcgis-10.1 file-geodatabase windows arccatalog
Can you post the script and any related screen shots to the task scheduler and/or the lock you mentioned.
– whyzar
Dec 20 '16 at 15:49
add a comment |
I am currently downloading and unzipping a GDB every night through the use of Task Scheduler. Then I update a related GDB with the changed features in all of the feature classes.
My issue is, the scheduled task script to download and unzip the GDB is creating a lock on the nightly downloaded GDB. This isn't an issue until I run the script on the next night.
My "try and except" statement to delete the previous GDB allows for the script to run but obviously doesn't delete the script do to my computer lock still being on the GDB.
I tried to delete the lock manually through windows explorer but it doesn't work. It seems that the schedule task manager just holds on to the lock.
This is my first experience with running a script through task scheduler where I actually need to delete an object created by the task scheduler. the only way I've found to unlock the GDB is by restarting my computer.
Code:
import arcpy, os, re, zipfile, shutil
import datetime as dt
from arcpy import *
#Relevant Dates
today = dt.date.today()
yesterday = today - dt.timedelta(days = 1)
#Create Target GDB
print "Creating GDB {0}".format(today)
env.overwriteOutput = True
outLocation = r'C:XXXYYYYYZZZZZ GDB'####Update Location with Shared Drive
GDBName = "Pathfinder {0}.gdb".format(today)
GDB = os.path.join (outLocation, GDBName)
arcpy.CreateFileGDB_management (outLocation, GDBName)
#Copied File Location and Unzip
print "Finding Zipped Folder"
sourceFolder = r'C:XXXYYYYYZZZZZExtracts'####Update Location with Pathfinder Data Dump folder
for (dirname, dirs, files) in os.walk(sourceFolder):
for filename in files:
if filename.startswith ("Location"):####Update Location with Pathfinder extract
zipFl = os.path.join(dirname, filename)
print "Copying Zipped File: {0}".format(zipFl)
copyLoc = r'C:XXXYYYYYZZZZZ Export'#####Update Location with shared drive copied folder
shutil.copyfile(zipFl, os.path.join(copyLoc, os.path.basename(zipFl)))
print "Unzipping File: {0}".format(zipFl)
zipFl = os.path.join(copyLoc, os.path.basename(zipFl))
zipOb = zipfile.ZipFile (zipFl, "r")
zipOb.extractall(GDB)
zipOb.close()
#Clean Up Folders
print "Deleting File: {0}".format(zipFl)
os.remove(zipFl)
yesterName = "Pathfinder {0}".format(yesterday)
yesterdayGDB = os.path.join(outLocation, yesterName)
try:
arcpy.Delete_management(yesterdayGDB)
print "Deleted {0}".format(yesterdayGDB)
except: print "Pathfinder {0}.gdb does not exist".format(yesterdayGDB)
print "Finished"
ArcGIS 10.1
Intel(R) Xeon(R) CPU E5-1607 0 @ 3.00 GHz
RAM: 16 GB
64 bit OS
arcpy arcgis-10.1 file-geodatabase windows arccatalog
I am currently downloading and unzipping a GDB every night through the use of Task Scheduler. Then I update a related GDB with the changed features in all of the feature classes.
My issue is, the scheduled task script to download and unzip the GDB is creating a lock on the nightly downloaded GDB. This isn't an issue until I run the script on the next night.
My "try and except" statement to delete the previous GDB allows for the script to run but obviously doesn't delete the script do to my computer lock still being on the GDB.
I tried to delete the lock manually through windows explorer but it doesn't work. It seems that the schedule task manager just holds on to the lock.
This is my first experience with running a script through task scheduler where I actually need to delete an object created by the task scheduler. the only way I've found to unlock the GDB is by restarting my computer.
Code:
import arcpy, os, re, zipfile, shutil
import datetime as dt
from arcpy import *
#Relevant Dates
today = dt.date.today()
yesterday = today - dt.timedelta(days = 1)
#Create Target GDB
print "Creating GDB {0}".format(today)
env.overwriteOutput = True
outLocation = r'C:XXXYYYYYZZZZZ GDB'####Update Location with Shared Drive
GDBName = "Pathfinder {0}.gdb".format(today)
GDB = os.path.join (outLocation, GDBName)
arcpy.CreateFileGDB_management (outLocation, GDBName)
#Copied File Location and Unzip
print "Finding Zipped Folder"
sourceFolder = r'C:XXXYYYYYZZZZZExtracts'####Update Location with Pathfinder Data Dump folder
for (dirname, dirs, files) in os.walk(sourceFolder):
for filename in files:
if filename.startswith ("Location"):####Update Location with Pathfinder extract
zipFl = os.path.join(dirname, filename)
print "Copying Zipped File: {0}".format(zipFl)
copyLoc = r'C:XXXYYYYYZZZZZ Export'#####Update Location with shared drive copied folder
shutil.copyfile(zipFl, os.path.join(copyLoc, os.path.basename(zipFl)))
print "Unzipping File: {0}".format(zipFl)
zipFl = os.path.join(copyLoc, os.path.basename(zipFl))
zipOb = zipfile.ZipFile (zipFl, "r")
zipOb.extractall(GDB)
zipOb.close()
#Clean Up Folders
print "Deleting File: {0}".format(zipFl)
os.remove(zipFl)
yesterName = "Pathfinder {0}".format(yesterday)
yesterdayGDB = os.path.join(outLocation, yesterName)
try:
arcpy.Delete_management(yesterdayGDB)
print "Deleted {0}".format(yesterdayGDB)
except: print "Pathfinder {0}.gdb does not exist".format(yesterdayGDB)
print "Finished"
ArcGIS 10.1
Intel(R) Xeon(R) CPU E5-1607 0 @ 3.00 GHz
RAM: 16 GB
64 bit OS
arcpy arcgis-10.1 file-geodatabase windows arccatalog
arcpy arcgis-10.1 file-geodatabase windows arccatalog
edited 12 mins ago
kShort
asked Dec 20 '16 at 15:46
kShortkShort
766
766
Can you post the script and any related screen shots to the task scheduler and/or the lock you mentioned.
– whyzar
Dec 20 '16 at 15:49
add a comment |
Can you post the script and any related screen shots to the task scheduler and/or the lock you mentioned.
– whyzar
Dec 20 '16 at 15:49
Can you post the script and any related screen shots to the task scheduler and/or the lock you mentioned.
– whyzar
Dec 20 '16 at 15:49
Can you post the script and any related screen shots to the task scheduler and/or the lock you mentioned.
– whyzar
Dec 20 '16 at 15:49
add a comment |
1 Answer
1
active
oldest
votes
I am guessing you have an instance of the task still running.
- Check windows task manager for python processes. add a return or a sys.exit() to the script.
- Configure the task to terminate after a certain time.
- Configure the first task to make a copy of the GDB and delete the original downloaded/unzipped files (since it has exclusive locks on it already. Hopefully the copy isn't locked
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f222101%2fcomputer-locking-gdb-when-running-scheduled-task%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am guessing you have an instance of the task still running.
- Check windows task manager for python processes. add a return or a sys.exit() to the script.
- Configure the task to terminate after a certain time.
- Configure the first task to make a copy of the GDB and delete the original downloaded/unzipped files (since it has exclusive locks on it already. Hopefully the copy isn't locked
add a comment |
I am guessing you have an instance of the task still running.
- Check windows task manager for python processes. add a return or a sys.exit() to the script.
- Configure the task to terminate after a certain time.
- Configure the first task to make a copy of the GDB and delete the original downloaded/unzipped files (since it has exclusive locks on it already. Hopefully the copy isn't locked
add a comment |
I am guessing you have an instance of the task still running.
- Check windows task manager for python processes. add a return or a sys.exit() to the script.
- Configure the task to terminate after a certain time.
- Configure the first task to make a copy of the GDB and delete the original downloaded/unzipped files (since it has exclusive locks on it already. Hopefully the copy isn't locked
I am guessing you have an instance of the task still running.
- Check windows task manager for python processes. add a return or a sys.exit() to the script.
- Configure the task to terminate after a certain time.
- Configure the first task to make a copy of the GDB and delete the original downloaded/unzipped files (since it has exclusive locks on it already. Hopefully the copy isn't locked
answered Dec 20 '16 at 17:24
Ben S NadlerBen S Nadler
1,526512
1,526512
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f222101%2fcomputer-locking-gdb-when-running-scheduled-task%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you post the script and any related screen shots to the task scheduler and/or the lock you mentioned.
– whyzar
Dec 20 '16 at 15:49